3 Replies Latest reply on Jul 7, 2005 5:36 PM by jason.greene

    JBossWS + Complex Types error

    adammeghji

      Hi,

      I'm trying to set up a web service with an EJB Endpoint, using a PHP-based SOAP client. One of the methods I'm calling takes in a Complex Type as a parameter, but dies when I try and access it.

      I believe my client is sending in the SOAP object with all types being String, and the server is failing to convert them to Integer when creating the object on the server. Is this true?

      Any input would be greatly appreciated. Thanks!


      Here's the error:

      18:25:16,585 ERROR [BeanPropertyTarget] Could not convert java.lang.String to bean field 'carrier_id', type java.lang.Integer
      18:25:16,585 ERROR [RPCInvocation] java.lang.IllegalArgumentException: argument type mismatch
      java.lang.IllegalArgumentException: argument type mismatch
       at org.jboss.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:243)
       at org.jboss.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:305)
       at org.jboss.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:590)
       at org.jboss.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1249)
       at org.jboss.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:252)
       at org.jboss.axis.message.SOAPElementAxisImpl.publishToHandler(SOAPElementAxisImpl.java:1386)
       at org.jboss.axis.message.RPCElement.deserialize(RPCElement.java:262)
       at org.jboss.axis.message.RPCElement.getParams(RPCElement.java:396)
       at org.jboss.axis.providers.java.RPCInvocation.prepareFromRequestEnvelope(RPCInvocation.java:235)
       at org.jboss.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:103)
       at org.jboss.axis.providers.java.JavaProvider.invoke(JavaProvider.java:358)
       at org.jboss.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
       at org.jboss.axis.SimpleChain.doVisiting(SimpleChain.java:160)
       at org.jboss.axis.SimpleChain.invoke(SimpleChain.java:123)
       at org.jboss.axis.handlers.soap.SOAPService.invoke(SOAPService.java:560)
      ...... etc.
      


      Here's my config.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
      
      <service name="CarrierService"
       targetNamespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"
       typeNamespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier/types"
       packageName="arm.carrier.interfaces">
      <interface name="arm.carrier.interfaces.CarrierFacadeService"/>
      </service>
      


      Here's my CarrierService.wsdl:
      <?xml version="1.0" encoding="UTF-8"?>
      
      <definitions name="CarrierService" targetNamespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"
      xmlns:tns="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier" xmlns="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:ns2="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier/types"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
       <types>
       <schema targetNamespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier/types"
      xmlns:tns="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier/types"
      xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns="http://www.w3.org/2001/XMLSchema">
       <complexType name="CarrierValue">
       <sequence>
       <element name="carrier_id" type="int" nillable="true"/>
       <element name="carrier_name" type="string" nillable="true"/>
       <element name="primaryKey" type="int" nillable="true"/></sequence></complexType></schema></types>
       <message name="CarrierFacadeService_createCarrier"/>
       <message name="CarrierFacadeService_createCarrierResponse">
       <part name="result" type="xsd:int"/></message>
       <message name="CarrierFacadeService_getCarrier">
       <part name="Integer_1" type="xsd:int"/></message>
       <message name="CarrierFacadeService_getCarrierResponse">
       <part name="result" type="ns2:CarrierValue"/></message>
       <message name="CarrierFacadeService_getCarrierNameService"/>
       <message name="CarrierFacadeService_getCarrierNameServiceResponse">
       <part name="result" type="xsd:string"/></message>
       <message name="CarrierFacadeService_updateCarrier">
       <part name="CarrierValue_1" type="ns2:CarrierValue"/></message>
       <message name="CarrierFacadeService_updateCarrierResponse"/>
       <portType name="CarrierFacadeService">
       <operation name="createCarrier">
       <input message="tns:CarrierFacadeService_createCarrier"/>
       <output message="tns:CarrierFacadeService_createCarrierResponse"/></operation>
       <operation name="getCarrier" parameterOrder="Integer_1">
       <input message="tns:CarrierFacadeService_getCarrier"/>
       <output message="tns:CarrierFacadeService_getCarrierResponse"/></operation>
       <operation name="getCarrierNameService">
       <input message="tns:CarrierFacadeService_getCarrierNameService"/>
       <output message="tns:CarrierFacadeService_getCarrierNameServiceResponse"/></operation>
       <operation name="updateCarrier" parameterOrder="CarrierValue_1">
       <input message="tns:CarrierFacadeService_updateCarrier"/>
       <output message="tns:CarrierFacadeService_updateCarrierResponse"/></operation></portType>
       <binding name="CarrierFacadeServiceBinding" type="tns:CarrierFacadeService">
       <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
       <operation name="createCarrier">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></input>
       <output>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></output></operation>
       <operation name="getCarrier">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></input>
       <output>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></output></operation>
       <operation name="getCarrierNameService">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></input>
       <output>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></output></operation>
       <operation name="updateCarrier">
       <soap:operation soapAction=""/>
       <input>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></input>
       <output>
       <soap:body use="literal" namespace="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"/></output></operation></binding>
       <service name="CarrierService">
       <port name="CarrierFacadeServicePort" binding="tns:CarrierFacadeServiceBinding">
       <soap:address location="REPLACE_WITH_ACTUAL_URL"/></port></service></definitions>
      


      Here's my mapping.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <java-wsdl-mapping xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
      http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd">
      <package-mapping>
      <package-type>arm.carrier.interfaces</package-type>
      <namespaceURI>http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier/types</namespaceURI>
      </package-mapping>
      <package-mapping>
      <package-type>arm.carrier.interfaces</package-type>
      <namespaceURI>http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier</namespaceURI>
      </package-mapping>
      <java-xml-type-mapping>
      <java-type>arm.carrier.interfaces.CarrierValue</java-type>
      <root-type-qname xmlns:typeNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier/types">typeNS:CarrierValue</root-type-qname>
      <qname-scope>complexType</qname-scope>
      <variable-mapping>
      <java-variable-name>carrier_id</java-variable-name>
      <xml-element-name>carrier_id</xml-element-name>
      </variable-mapping>
      <variable-mapping>
      <java-variable-name>carrier_name</java-variable-name>
      <xml-element-name>carrier_name</xml-element-name>
      </variable-mapping>
      <variable-mapping>
      <java-variable-name>primaryKey</java-variable-name>
      <xml-element-name>primaryKey</xml-element-name>
      </variable-mapping>
      </java-xml-type-mapping>
      <service-interface-mapping>
      <service-interface>arm.carrier.interfaces.CarrierService</service-interface>
      <wsdl-service-name xmlns:serviceNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">serviceNS:CarrierService</wsdl-service-name>
      <port-mapping>
      <port-name>CarrierFacadeServicePort</port-name>
      <java-port-name>CarrierFacadeServicePort</java-port-name>
      </port-mapping>
      </service-interface-mapping>
      <service-endpoint-interface-mapping>
      <service-endpoint-interface>arm.carrier.interfaces.CarrierFacadeService</service-endpoint-interface>
      <wsdl-port-type xmlns:portTypeNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">portTypeNS:CarrierFacadeService</wsdl-port-type>
      <wsdl-binding xmlns:bindingNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">bindingNS:CarrierFacadeServiceBinding</wsdl-binding>
      <service-endpoint-method-mapping>
      <java-method-name>createCarrier</java-method-name>
      <wsdl-operation>createCarrier</wsdl-operation>
      <wsdl-return-value-mapping>
      <method-return-value>java.lang.Integer</method-return-value>
      <wsdl-message xmlns:wsdlMsgNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">wsdlMsgNS:CarrierFacadeService_createCarrierResponse</wsdl-message>
      <wsdl-message-part-name>result</wsdl-message-part-name>
      </wsdl-return-value-mapping>
      </service-endpoint-method-mapping>
      <service-endpoint-method-mapping>
      <java-method-name>getCarrier</java-method-name>
      <wsdl-operation>getCarrier</wsdl-operation>
      <method-param-parts-mapping>
      <param-position>0</param-position>
      <param-type>java.lang.Integer</param-type>
      <wsdl-message-mapping>
      <wsdl-message xmlns:wsdlMsgNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">wsdlMsgNS:CarrierFacadeService_getCarrier</wsdl-message>
      <wsdl-message-part-name>Integer_1</wsdl-message-part-name>
      <parameter-mode>IN</parameter-mode>
      </wsdl-message-mapping>
      </method-param-parts-mapping>
      <wsdl-return-value-mapping>
      <method-return-value>arm.carrier.interfaces.CarrierValue</method-return-value>
      <wsdl-message xmlns:wsdlMsgNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">wsdlMsgNS:CarrierFacadeService_getCarrierResponse</wsdl-message>
      <wsdl-message-part-name>result</wsdl-message-part-name>
      </wsdl-return-value-mapping>
      </service-endpoint-method-mapping>
      <service-endpoint-method-mapping>
      <java-method-name>getCarrierNameService</java-method-name>
      <wsdl-operation>getCarrierNameService</wsdl-operation>
      <wsdl-return-value-mapping>
      <method-return-value>java.lang.String</method-return-value>
      <wsdl-message xmlns:wsdlMsgNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">wsdlMsgNS:CarrierFacadeService_getCarrierNameServiceResponse</wsdl-message>
      <wsdl-message-part-name>result</wsdl-message-part-name>
      </wsdl-return-value-mapping>
      </service-endpoint-method-mapping>
      <service-endpoint-method-mapping>
      <java-method-name>updateCarrier</java-method-name>
      <wsdl-operation>updateCarrier</wsdl-operation>
      <method-param-parts-mapping>
      <param-position>0</param-position>
      <param-type>arm.carrier.interfaces.CarrierValue</param-type>
      <wsdl-message-mapping>
      <wsdl-message xmlns:wsdlMsgNS="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier">wsdlMsgNS:CarrierFacadeService_updateCarrier</wsdl-message>
      <wsdl-message-part-name>CarrierValue_1</wsdl-message-part-name>
      <parameter-mode>IN</parameter-mode>
      </wsdl-message-mapping>
      </method-param-parts-mapping>
      </service-endpoint-method-mapping>
      </service-endpoint-interface-mapping>
      </java-wsdl-mapping>
      


        • 1. Re: JBossWS + Complex Types error
          jason.greene

          Can you get a copy of the SOAP request the PHP client is sending?

          -Jason

          • 2. Re: JBossWS + Complex Types error
            adammeghji

            Sure. Here's the SOAP request.

            <?xml version="1.0" encoding="UTF-8"?>
            
            <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/"
             xmlns:ns4="http://192.168.110.11:8081/thirdapp/thirdappEJB/Carrier"
             SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <SOAP-ENV:Body>
            
            <ns4:updateCarrier>
            <CarrierValue_1 xsi:type="ns4:CarrierValue">
            <carrier_id xsi:type="xsd:string">1</carrier_id>
            <carrier_name xsi:type="xsd:string">poop0.45616600 1120766530</carrier_name>
            <primaryKey xsi:type="xsd:string">1</primaryKey></CarrierValue_1></ns4:updateCarrier>
            </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>


            In looking at that, I believe my initial question is answered -- I'm sending over a type "xsd:string", which obviously isn't an Integer. I tried explicitly casting the Integers fields from the default string type to (int) and the query worked:
            <ns4:updateCarrier>
            <CarrierValue_1 xsi:type="ns4:CarrierValue">
            <carrier_id xsi:type="xsd:int">1</carrier_id>
            
            <carrier_name xsi:type="xsd:string">poop0.38294000 1120766835</carrier_name>
            <primaryKey xsi:type="xsd:int">1</primaryKey></CarrierValue_1></ns4:updateCarrier>


            I was using strings in the first place because that was what had been returned by the Service in a previous operation: getCarrier(), returning CarrierValue.

            Let me re-phrase my problem. One of my operations is returning a ComplexType comprised of strings, or more likely, untyped data. (PHP defaults to String type).

            Is there anything in my configuration that would explain why the getCarrier operation isn't returning Object contents of the right type?



            • 3. Re: JBossWS + Complex Types error
              jason.greene

              xsi:type usually indicates rpc/encoding, which is probably what the php soap library is doing. Basically with encoding you pass all of the type information at runtime, instead of negotiating it in advance with schema. So in most literal requests you will never see the xsi:type attribute because it is redundant, and it increases the size of the message. An example of a literal message that would use xsi:type is one that involves inheritence (a message takes a base type, and the sender passes a derived type).

              getCarrier is behaving correctly by not including the type information in the request.

              So basically you need to use a php soap library that supports rpc/literal or doc/literal. I believe that php 5 includes such an implementation.

              -Jason