This is my WSDL file view.
<s:element name="ManageUser">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Scenario" type="tns:ManageUserScenario"/>
<s:element minOccurs="0" maxOccurs="1" name="Language" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Userguid" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Email" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Firstname" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Lastname" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Address" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="District" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Province" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Postcode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Phone" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="Newsletter" type="tns:SubscribeNewsletter"/>
</s:sequence>
</s:complexType>
</s:element>
<s:simpleType name="ManageUserScenario">
<s:restriction base="s:string">
<s:enumeration value="Create"/>
<s:enumeration value="Update"/>
</s:restriction>
</s:simpleType>
<s:simpleType name="SubscribeNewsletter">
<s:restriction base="s:string">
<s:enumeration value="X"/>
<s:enumeration value="N"/>
</s:restriction>
</s:simpleType>
How can i set request for this. This is my code where i am getting no response but warnings. Please tell me where i am wrong. My code:
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD);
request.addProperty("Scenario", "Create");
request.addProperty("Language", "en");
request.addProperty("Username", "abc");
request.addProperty("Email", "abc@gmail.com");
request.addProperty("Password", "abc");
request.addProperty("Firstname", "kumar");
request.addProperty("Lastname", "aryan");
request.addProperty("Userguid", "");
request.addProperty("Phone", "0000000000");
request.addProperty("Address", "");
request.addProperty("District", "");
request.addProperty("Province", "");
request.addProperty("Country", "India");
request.addProperty("Postcode", "");
request.addProperty("Newsletter", "X");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SOAP_VERSION);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
Log.e("Try Block 1", envelope + " - " + request);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result1 = (SoapObject) envelope.bodyIn;
Also i am getting this in log:
W/System.err(32420): org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT To register an ...@2:166 in java.io.InputStreamReader@42885270)
: at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:2045)
: at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:275)
: at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
: at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
: at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
: at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
: at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
: at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
: at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
: at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:273)
: at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:389)
: at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:151)
: at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
: at org.ksoap2.transport.Transport.parseResponse(Transport.java:118)
: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:253)
: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)
: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111)
: at com.chilindo.SignUpActivity$AsyncTaskRunner.doInBackground(SignUpActivity.java:193)
Any help is appreciated, Thank you.
Hi this is the complex way of using wsdl api.
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(NAMESPACE + "users.asmx");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.encodingStyle = SoapEnvelope.ENC;
String bodyOut = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
bodyOut += "<soap:Body><" + METHOD + " xmlns=\""
+ NAMESPACE + "\">";
bodyOut += "<Scenario>" + "Create"
+ "</Scenario><Language>"
+ R.string.language
+ "</Language>"
+ "<Userguid>"
+ ""
+ "</Userguid><Username>"
+ str_username
+ "</Username>"
+ "<Email>"
+ str_email
+ "</Email> <Password>"
+ str_password
+ "</Password><Firstname>"
+ str_first_name
+ "</Firstname>"
+ " <Lastname>"
+ str_last_name
+ "</Lastname><Address>"
+ ""
+ "</Address><District>"
+ ""
+ "</District>"
+ "<Province>"
+ ""
+ "</Province><Country>"
+ str_country
+ "</Country><Postcode>"
+ ""
+ "</Postcode>"
+ "<Phone>"
+ str_phone
+ "</Phone><Newsletter>"
+ news_letter
+ "</Newsletter>";
bodyOut += "</" + METHOD + "></soap:Body></soap:Envelope>";
String xml2 = bodyOut;
// System.out.println("Body " + xml2);
StringEntity se = new StringEntity(xml2, HTTP.UTF_8);
se.setContentType("text/xml");
httpPost.addHeader(SOAP_ACTION, NAMESPACE + "users.asmx");
httpPost.setEntity(se);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity resEntity = httpResponse.getEntity();
String xml = EntityUtils.toString(resEntity);