axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Gornick <sgorn...@digicoast.com>
Subject SAXException Bad types - complex type - holder issue?
Date Fri, 07 Mar 2003 18:41:31 GMT
I am getting SAXException Bad types
    (class RemotableExampleTypes.TExample -> int)
and do not know how to diagnose the problem.

My web service is a Delphi 7 app, so I used
WSDL2Java to create the bindings from the WSDL.

The GetCust operation responds with the complex
type TExample.  Any help greatly appreciated!

Here is the WSDL:
<?xml version="1.0" encoding="utf-8"?>
<definitions
 xmlns="http://schemas.xmlsoap.org/wsdl/"
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
 name="IRemotableExampleservice"
 targetNamespace="http://tempuri.org/"
 xmlns:tns="http://tempuri.org/"
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
 xmlns:ns1="urn:RemotableExampleTypes">
<types>
 <xs:schema targetNamespace="urn:RemotableExampleTypes"
   xmlns="urn:RemotableExampleTypes">
  <xs:complexType name="TExample">
   <xs:sequence>
    <xs:element name="CustNo" type="xs:int"/>
    <xs:element name="Name" type="xs:string"/>
    <xs:element name="Addr" type="xs:string"/>
    <xs:element name="City" type="xs:string"/>
    <xs:element name="State" type="xs:string"/>
    <xs:element name="Phone" type="xs:string"/>
    <xs:element name="ZipCode" type="xs:string"/>
   </xs:sequence>
  </xs:complexType>
 </xs:schema>
</types>
<message name="GetCust0Request">
 <part name="Value" type="xs:int"/>
</message>
<message name="GetCust0Response">
 <part name="Example" type="ns1:TExample"/>
 <part name="return" type="xs:int"/>
</message>
<message name="PutCust1Request">
 <part name="Value" type="ns1:TExample"/>
</message>
<message name="PutCust1Response">
 <part name="return" type="xs:int"/>
</message>
<portType name="IRemotableExample">
 <operation name="GetCust">
  <input message="tns:GetCust0Request"/>
  <output message="tns:GetCust0Response"/>
 </operation>
 <operation name="PutCust">
  <input message="tns:PutCust1Request"/>
  <output message="tns:PutCust1Response"/>
 </operation>
</portType>
<binding name="IRemotableExamplebinding"
  type="tns:IRemotableExample">
<soap:binding style="rpc"
  transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetCust">
 <soap:operation
   soapAction="urn:RemotableExampleIntf-IRemotableExample#GetCust"
   style="rpc"/>
 <input message="tns:GetCust0Request">
  <soap:body use="encoded"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="urn:RemotableExampleIntf-IRemotableExample"/>
 </input>
 <output message="tns:GetCust0Response">
  <soap:body use="encoded"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="urn:RemotableExampleIntf-IRemotableExample"/>
 </output>
</operation>
<operation name="PutCust">
 <soap:operation
   soapAction="urn:RemotableExampleIntf-IRemotableExample#PutCust"
   style="rpc"/>
 <input message="tns:PutCust1Request">
  <soap:body use="encoded"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="urn:RemotableExampleIntf-IRemotableExample"/>
 </input>
 <output message="tns:PutCust1Response">
  <soap:body use="encoded"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="urn:RemotableExampleIntf-IRemotableExample"/>
 </output>
</operation>
</binding>
<service name="IRemotableExampleservice">
 <port name="IRemotableExamplePort"
   binding="tns:IRemotableExamplebinding">
  <soap:address
    location="http://localhost:5097/soap/IRemotableExample"/>
 </port>
</service>
</definitions>

Here is Client1.java
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.XMLType;
import javax.xml.namespace.QName;
import org.apache.axis.AxisFault;
import org.tempuri.*;
import java.net.URL;

public class Client1
{
 public static void main(String[] args) throws Exception
 {
   String endpointURL = "http://localhost:5097/soap/IRemotableExample";

   Service service = new Service();
   Call call = (Call) service.createCall();
   call.setTargetEndpointAddress(new java.net.URL(endpointURL));

   RemotableExampleTypes.TExample example =
     new RemotableExampleTypes.TExample();

   // register the TExample class
   QName teqn = new QName("urn:RemotableExampleTypes", "TExample");
   Class tecls = RemotableExampleTypes.TExample.class;
   call.registerTypeMapping(tecls, teqn,
         BeanSerializerFactory.class,
         BeanDeserializerFactory.class);

   RemotableExampleTypes.holders.TExampleHolder exampleHolder =
      new RemotableExampleTypes.holders.TExampleHolder();

   call.setOperationName(new QName("", "GetCust"));
   call.addParameter(
     "Value", XMLType.XSD_INT, javax.xml.rpc.ParameterMode.IN);
   call.addParameter("Example", teqn, javax.xml.rpc.ParameterMode.INOUT);

   call.setReturnType(XMLType.XSD_INT);

   Object ret =
     call.invoke(new Object[] {new String ("0"), exampleHolder.value});

   if (null == ret) {
     System.out.println("Received null ");
     throw new AxisFault("", "Received null", null, null);
   }

   if (ret instanceof String) {
     System.out.println(ret);
   }
   if (ret instanceof Integer) {
     System.out.println(ret);
   }
 }
}


The response from the web service (using TCPMon) is:
<?xml version="1.0"?>
<SOAP-ENV:Envelope
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body
  SOAP-ENC:encodingStyle="http://schemas.xmlsoap.org/soap/envelope/">
 <NS1:GetCustResponse
   xmlns:NS1="urn:RemotableExampleIntf-IRemotableExample"
   xmlns:NS2="urn:RemotableExampleTypes">
  <return xsi:type="xsd:int">0</return>
  <NS2:TExample id="1" xsi:type="NS2:TExample">
   <CustNo xsi:type="xsd:int">0</CustNo>
   <Name xsi:type="xsd:string">Dennis Passmore</Name>
   <Addr xsi:type="xsd:string">1234 Some St.</Addr>
   <City xsi:type="xsd:string">Some City</City>
   <State xsi:type="xsd:string">Some State</State>
   <Phone xsi:type="xsd:string">123-456-6789</Phone>
   <ZipCode xsi:type="xsd:string">12345</ZipCode>
  </NS2:TExample>
  <Example href="#1"/>
 </NS1:GetCustResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The following is the error message Client1 reports::

Mar 6, 2003 10:21:15 PM org.apache.axis.client.Call invoke
SEVERE: Exception:
org.xml.sax.SAXException: Bad types (class 
RemotableExampleTypes.TExample -> int)
 at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:306)
 at org.apache.axis.encoding.DeserializationContextImpl.startElement(
        DeserializationContextImpl.java:921)
 at org.apache.axis.message.SAX2EventRecorder.replay(
         SAX2EventRecorder.java:198)
 at org.apache.axis.message.MessageElement.publishToHandler(
         MessageElement.java:699)
 at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:307)
 at org.apache.axis.message.RPCElement.getParams(RPCElement.java:331)
 at org.apache.axis.client.Call.invoke(Call.java:2200)
 at org.apache.axis.client.Call.invoke(Call.java:2099)
 at org.apache.axis.client.Call.invoke(Call.java:1622)
 at Client1.main(Client1.java:41)
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Bad types
    (class RemotableExampleTypes.TExample -&gt; int)
faultActor:
faultNode:
faultDetail:
 {http://xml.apache.org/axis/}stackTrace:
     org.xml.sax.SAXException: Bad types (class 
RemotableExampleTypes.TExample -&gt; int)
at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:306)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(
    DeserializationContextImpl.java:921)
at org.apache.axis.message.SAX2EventRecorder.replay(
    SAX2EventRecorder.java:198)
at org.apache.axis.message.MessageElement.publishToHandler(
    MessageElement.java:699)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:307)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:331)
at org.apache.axis.client.Call.invoke(Call.java:2200)
at org.apache.axis.client.Call.invoke(Call.java:2099)
at org.apache.axis.client.Call.invoke(Call.java:1622)
at Client1.main(Client1.java:41)

Other relevant info:
Using Axis 1.1 RC1
The source for the Delphi 7 web service is here:
http://www.dpassmore.com/wdata/RemotableExample.zip


Mime
View raw message