Hi all,
   I am trying to call ofbiz web service "userLogin" from external java client. 
I have made export="true" in services.xml file for "userLogin"  service. Also I 
am able to get the WSDL of it. But when I try to call it from external java 
client, it gives some error. The wsdl generated, java client code and error 
console is given below:


−
<wsdl:types>
−

−
<xsd:element name="std-String">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="std-Integer">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:integer" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="std-Long">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:long" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="std-Float">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:float" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="std-Double">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:double" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="std-Boolean">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:boolean" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="std-Locale">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="sql-Timestamp">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:dateTime" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="sql-Date">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:date" use="required"/>
</xsd:complexType>
</xsd:element>
−
<xsd:element name="sql-Time">
−
<xsd:complexType>
<xsd:attribute name="value" type="xsd:time" use="required"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="col-ArrayList" type="tns:col-Collection"/>
<xsd:element name="col-LinkedList" type="tns:col-Collection"/>
<xsd:element name="col-Stack" type="tns:col-Collection"/>
<xsd:element name="col-Vector" type="tns:col-Collection"/>
<xsd:element name="col-TreeSet" type="tns:col-Collection"/>
<xsd:element name="col-HashSet" type="tns:col-Collection"/>
<xsd:element name="col-Collection" type="tns:col-Collection"/>
<xsd:element name="map-TreeMap" type="tns:map-Map"/>
<xsd:element name="map-WeakHashMap" type="tns:map-Map"/>
<xsd:element name="map-Hashtable" type="tns:map-Map"/>
<xsd:element name="map-Properties" type="tns:map-Map"/>
<xsd:element name="map-HashMap" type="tns:map-Map"/>
<xsd:element name="map-Map" type="tns:map-Map"/>
<xsd:element name="map-Entry" type="tns:map-Entry"/>
<xsd:element name="map-Key" type="tns:map-Key"/>
<xsd:element name="map-Value" type="tns:map-Value"/>
−
<xsd:element name="eepk-" type="tns:map-Map">
−
<xsd:annotation>
−
<xsd:documentation>
The name of element need to be appended with name of entity such as 
eepk-Product 
for Product entity.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
−
<xsd:element name="eeval-" type="tns:map-Map">
−
<xsd:annotation>
−
<xsd:documentation>
The name of element need to be appended with name of entity such as 
eeval-Product for Product entity.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
−
<xsd:element name="cus-obj">
−
<xsd:annotation>
−
<xsd:documentation>
Object content need to be in CDATA such as 
<cus-obj><![CDATA[--byteHex--]]></cus-obj>
</xsd:documentation>
</xsd:annotation>
</xsd:element>
−
<xsd:complexType name="map-Map">
−
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:map-Entry"/>
</xsd:sequence>
</xsd:complexType>
−
<xsd:complexType name="map-Entry">
−
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-Key"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-Value"/>
</xsd:sequence>
</xsd:complexType>
−
<xsd:complexType name="map-Key">
−
<xsd:all>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-String"/>
</xsd:all>
</xsd:complexType>
−
<xsd:complexType name="map-Value">
−
<xsd:choice>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-String"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-Integer"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-Long"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-Float"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-Double"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-Boolean"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:std-Locale"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:sql-Timestamp"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:sql-Date"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:sql-Time"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:col-ArrayList"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:col-LinkedList"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:col-Stack"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:col-Vector"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:col-TreeSet"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:col-HashSet"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:col-Collection"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-HashMap"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-Properties"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-Hashtable"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-WeakHashMap"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-TreeMap"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:map-Map"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:eepk-"/>
<xsd:element maxOccurs="1" minOccurs="1" ref="tns:eeval-"/>
</xsd:choice>
</xsd:complexType>
−
<xsd:complexType name="col-Collection">
−
<xsd:choice>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:std-String"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:std-Integer"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:std-Long"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:std-Float"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:std-Double"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:std-Boolean"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:std-Locale"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:sql-Timestamp"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:sql-Date"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:sql-Time"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:col-ArrayList"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:col-LinkedList"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:col-Stack"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:col-Vector"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:col-TreeSet"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:col-HashSet"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:col-Collection"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:map-HashMap"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:map-Properties"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:map-Hashtable"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:map-WeakHashMap"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:map-TreeMap"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:map-Map"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:eepk-"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="tns:eeval-"/>
</xsd:choice>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
−
<wsdl:message name="userLoginRequest">
−
<wsdl:part name="map-Map" type="tns:map-Map">
−
<wsdl:documentation>




</wsdl:documentation>
</wsdl:part>
</wsdl:message>
−
<wsdl:message name="userLoginResponse">
−
<wsdl:part name="map-Map" type="tns:map-Map">
−
<wsdl:documentation>

</wsdl:documentation>
</wsdl:part>
</wsdl:message>
−
<wsdl:portType name="userLoginPortType">
−
<wsdl:operation name="userLogin">
<wsdl:input message="tns:userLoginRequest"/>
<wsdl:output message="tns:userLoginResponse"/>
</wsdl:operation>
</wsdl:portType>
−
<wsdl:binding name="userLoginSoapBinding" type="tns:userLoginPortType">
http://schemas.xmlsoap.org/soap/http"/>
−
<wsdl:operation name="userLogin">

−
<wsdl:input>

</wsdl:input>
−
<wsdl:output>

</wsdl:output>
</wsdl:operation>
</wsdl:binding>
−
<wsdl:service name="userLogin">
−
<wsdl:port binding="tns:userLoginSoapBinding" name="userLoginPort">
http://localhost:7080/webtools/control/SOAPService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

-----------------------------------------------------------------------------------------------------------------

And the java client code is:



import java.awt.List;
import java.net.URL;
import java.util.Map;

import javax.xml.namespace.QName;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class Sample
{
   public static void main(String [] args) throws Exception
         {
            try
                {
                    String endPoint = 
"http://localhost:7080/webtools/control/SOAPService";;
                    Call call = (Call)new Service().createCall();
                    call.setTargetEndpointAddress(new URL(endPoint));
                    call.setOperationName(new 
QName("http://ofbiz.apache.org/service/","userLogin";));
                    System.out.println("*******call.add parameterl********");
                    List inputList = new List();
                    inputList.add("admin");
                    inputList.add("ofbiz");
                    
call.addParameter("username",org.apache.axis.Constants.SOAP_STRING, 
javax.xml.rpc.ParameterMode.IN);
                    
call.addParameter("password",org.apache.axis.Constants.SOAP_STRING,javax.xml.rpc.ParameterMode.IN);

                    call.setReturnType(org.apache.axis.Constants.SOAP_VECTOR);
                    System.out.println("*******call invoking********");
                    Object responseWS=call.invoke(new 
Object[]{"admin","ofbiz"});
                    Map output = call.getOutputParams();
                    System.out.println("call invoked...");
                }
                catch(Exception exp)
                {
                    exp.printStackTrace();
                }

       
       
         }
}

-------------------------------------------------------------------------------------------------


And the error console is:


12 Jan, 2011 10:44:19 AM org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and 
javax.mail.internet.MimeMultipart). Attachment support is disabled.
*******call.add parameterl********
*******call invoking********
12 Jan, 2011 10:44:20 AM org.apache.axis.client.Call invoke
SEVERE: Exception:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which 
is NOT expected, in something it was trying to deserialize.
    at 
org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)

    at 
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)

    at 
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at 
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)

    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.test.sample.Sample.main(Sample.java:34)
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child 
element, which is NOT expected, in something it was trying to deserialize.
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: 
SimpleDeserializer encountered a child element, which is NOT expected, in 
something it was trying to deserialize.
    at 
org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)

    at 
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)

    at 
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at 
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)

    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.test.sample.Sample.main(Sample.java:34)

    {http://xml.apache.org/axis/}hostname:sanjay-desktop

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which 
is NOT expected, in something it was trying to deserialize.
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.client.Call.invoke(Call.java:2470)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at com.test.sample.Sample.main(Sample.java:34)
Caused by: org.xml.sax.SAXException: SimpleDeserializer encountered a child 
element, which is NOT expected, in something it was trying to deserialize.
    at 
org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)

    at 
org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)

    at 
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at 
org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)

    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    ... 3 more


--------------------------------------------------------------------------------

I cant understand where I am wrong?
I am stuck up completely, need guidance...
ASAP.


Thanks and Regards,
Sanjay Kumar

Ofbiz Trainee.



      

Reply via email to