Hi Guys,
I am developing a mobile application using J2ME, LWUIT and KSOAP. The application makes .net webservice calls and fetches responses. I am able
to successfully make calls and receive respone, but not able
to parse the response, due
to my limited knowledge in java. following is my WSDL file and j2me code snippet used
to make calls. The WSDL file has complex and SIMPLETYPE elements, which needs
to be mapped
to JAVA classes. i request you guys
to help me out with any pointers or sample code.
WSDL file:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="Login">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userLoginID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="LoginResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="User" nillable="true" type="tns:UserBin" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="UserBin" abstract="true">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CompanyCodeSeqId" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="Image" type="s:base64Binary" />
<s:element minOccurs="1" maxOccurs="1" name="DateOfBirth" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="UserSeqId" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="UserFirstName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="UserLastName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PassWord" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="UserRole" type="tns:Roles" />
<s:element minOccurs="1" maxOccurs="1" name="UserSSN" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="EmailId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="MobileNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="CreatedDate" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="ModifiedDate" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="UserGroup" type="tns:UserGroups" />
<s:element minOccurs="1" maxOccurs="1" name="SecretQuestionID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="SecretAnswer" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="WorkPhone" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="HomePhone" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Company" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="PreviousLoginTime" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="LoginTime" type="s:dateTime" />
</s:sequence>
</s:complexType>
<s:simpleType name="Roles">
<s:restriction base="s:string">
<s:enumeration value="Guest" />
<s:enumeration value="Customer" />
<s:enumeration value="Driver" />
<s:enumeration value="Dispatcher" />
<s:enumeration value="CompanyCodeAdmin" />
</s:restriction>
</s:simpleType>
<s:simpleType name="UserGroups">
<s:restriction base="s:string">
<s:enumeration value="Invalid" />
<s:enumeration value="Customer" />
<s:enumeration value="Driver" />
<s:enumeration value="Dispatcher" />
</s:restriction>
</s:simpleType>
<s:complexType name="DriverBin">
<s:complexContent mixed="false">
<s:extension base="tns:UserBin">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="DriverGroupId" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="DriverTypeId" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="HireDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="LicenceNumber" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ExpiryDateForLicence" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="VehicleNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyPhone" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyAddress" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyRelationship" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="DriverType" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="DriverGroupName" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="VehicleID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="SocialSN" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="StreetAddress" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="City" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="State" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="Zip" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="EmergencyCity" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="EmergencyState" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyZip" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="TerminationDate" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="HireAgainFlag" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="TerminationReason" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Notes" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ImageName" type="s:string" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:complexType name="CustomerBin">
<s:complexContent mixed="false">
<s:extension base="tns:UserBin">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PassengesDetails" type="tns:ArrayOfPassengerBin" />
<s:element minOccurs="0" maxOccurs="1" name="CompanyName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CreditCardDetailsArray" type="tns:ArrayOfCreditCardDetailsBin" />
<s:element minOccurs="0" maxOccurs="1" name="AddressArray" type="tns:ArrayOfAddressBin" />
<s:element minOccurs="1" maxOccurs="1" name="CustomerCompanyID" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="CustomerType" type="tns:CustomerType" />
<s:element minOccurs="0" maxOccurs="1" name="PassengerGradeName" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="PassengerGradeID" type="s:int" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:complexType name="ArrayOfPassengerBin">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="PassengerBin" nillable="true" type="tns:PassengerBin" />
</s:sequence>
</s:complexType>
<s:complexType name="PassengerBin">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CustomerSeqID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="EmailID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="PhoneNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="LastName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="PassengerSeqID" nillable="true" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="IsSelf" type="s:boolean" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfCreditCardDetailsBin">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="CreditCardDetailsBin" nillable="true" type="tns:CreditCardDetailsBin" />
</s:sequence>
</s:complexType>
<s:complexType name="CreditCardDetailsBin">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CardSeqID" nillable="true" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="ExpiryYear" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="ExpiryMonth" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="CardType" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="NickName" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="CVVNumber" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="CreditCardNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="NameOnTheCard" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="IsPrimary" type="s:boolean" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfAddressBin">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="AddressBin" nillable="true" type="tns:AddressBin" />
</s:sequence>
</s:complexType>
<s:complexType name="AddressBin">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="UserSeqID" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="AddressID" nillable="true" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="ZipCode" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="IsPrimary" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="State" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="StateID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="StateCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="CityID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="StreetAddress" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="NickName" type="s:string" />
</s:sequence>
</s:complexType>
<s:simpleType name="CustomerType">
<s:restriction base="s:string">
<s:enumeration value="Individual" />
<s:enumeration value="Corporate" />
</s:restriction>
</s:simpleType>
<s:complexType name="DispatcherBin">
<s:complexContent mixed="false">
<s:extension base="tns:UserBin">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Address1" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Province" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="IsActive" type="s:boolean" />
<s:element minOccurs="1" maxOccurs="1" name="DispatcherHireDate" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="DispatcherSSN" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="TerminationDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="ReasonForTermination" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="HireAgainFlag" type="s:boolean" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyContactName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyContactNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyContactAddress" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmergencyContactRelationship" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="HireDate" type="s:dateTime" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:element name="Logout">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userLoginID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="userSeqID" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="validationKey" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="LogoutResponse">
<s:complexType />
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="LoginSoapIn">
<wsdl:part name="parameters" element="tns:Login" />
</wsdl:message>
<wsdl:message name="LoginSoapOut">
<wsdl:part name="parameters" element="tns:LoginResponse" />
</wsdl:message>
<wsdl:message name="LogoutSoapIn">
<wsdl:part name="parameters" element="tns:Logout" />
</wsdl:message>
<wsdl:message name="LogoutSoapOut">
<wsdl:part name="parameters" element="tns:LogoutResponse" />
</wsdl:message>
<wsdl:portType name="AccountManagementSoap">
<wsdl:operation name="Login">
<wsdl:input message="tns:LoginSoapIn" />
<wsdl:output message="tns:LoginSoapOut" />
</wsdl:operation>
<wsdl:operation name="Logout">
<wsdl:input message="tns:LogoutSoapIn" />
<wsdl:output message="tns:LogoutSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="AccountManagementSoap" type="tns:AccountManagementSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Login">
<soap:operation soapAction="http://tempuri.org/Login" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Logout">
<soap:operation soapAction="http://tempuri.org/Logout" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="AccountManagementSoap12" type="tns:AccountManagementSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Login">
<soap12:operation soapAction="http://tempuri.org/Login" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Logout">
<soap12:operation soapAction="http://tempuri.org/Logout" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="AccountManagement">
<wsdl:port name="AccountManagementSoap" binding="tns:AccountManagementSoap">
<soap:address location="http://webservice.mcubeit.com/trs_webservice/services/AccountManagement.asmx" />
</wsdl:port>
<wsdl:port name="AccountManagementSoap12" binding="tns:AccountManagementSoap12">
<soap12:address location="http://webservice.mcubeit.com/trs_webservice/services/AccountManagement.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
J2ME Code Snippet:
String uname = username.getText();
String pass = password.getText();
String serviceUrl = "http://xxx.xxx.xxx/webservice/services/AccountManagement.asmx";
String serviceNameSpace = "http://tempuri.org/";
String soapAction = "http://tempuri.org/Login";
String methodName = "Login";
SoapObject rpc = new SoapObject(serviceNameSpace, methodName);
rpc.addProperty("userLoginID", uname.trim());
rpc.addProperty("password", pass.trim());
//rpc.addProperty("userSeqID",
String.valueOf(192).toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
String result = null;
try {
ht.call(soapAction, envelope);
result = (envelope.getResponse()).toString();
System.out.println("Result :" + result.toString());
} catch (org.xmlpull.v1.XmlPullParserException ex2) {
System.out.println("XmlPullParserException :" + ex2.toString());
System.out.println("Request \n" + ht.requestDump);
System.out.println("Response \n" + ht.responseDump);
} catch (SoapFault sf) {
System.out.println("SoapFault :" + sf.faultstring);
System.out.println("Request \n" + ht.requestDump);
System.out.println("Response \n" + ht.responseDump);
} catch (IOException ioe) {
System.out.println("IOException :" + ioe.toString());
System.out.println("Request \n" + ht.requestDump);
System.out.println("Response \n" + ht.responseDump);
}
RESPONSE
Result :CustomerBin{CompanyCodeSeqId=-1; Image=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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fBirth=1900-01-01T00:00:00; UserSeqId=192; UserFirstName=Sachin; UserLastName=Nevase; PassWord=anyType{}; UserRole=Customer; UserSSN=-2147483648;
[email protected]; MobileNumber=804131244; CreatedDate=1900-01-01T00:00:00; ModifiedDate=1900-01-01T00:00:00; UserGroup=Customer; SecretQuestionID=-2147483648; SecretAnswer=anyType{}; WorkPhone=anyType{}; HomePhone=anyType{}; Company=anyType{}; PreviousLoginTime=2010-05-04T23:38:34; LoginTime=1900-01-01T00:00:00; PassengesDetails=anyType{PassengerBin=anyType{CustomerSeqID=192;
[email protected]; PhoneNumber=0804131244; LastName=Nevase; FirstName=Sachin; PassengerSeqID=55; IsSelf=true; }; }; CustomerCompanyID=-1; CustomerType=Individual; PassengerGradeName=Grade1; PassengerGradeID=1; }
Thanks,
Sachin