Hi all,

I am trying to get a response from a web service. I am supposed to
send to the server something like :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/
envelope/"
xmlns:ont="http://myserver.com/";>
   <soapenv:Header>
      <ont:AuthHeaderElement>
         <username>Username</username>
         <password>Password</password>
      </ont:AuthHeaderElement>
   </soapenv:Header>
   <soapenv:Body>
      <ont:SearchSolution>
         <manufacturer>string</manufacturer>
         <product_group>string</product_group>
         <product>string</product>
         <failure_appearance>string</failure_appearance>
         <symptom_code></symptom_code>
         <diag_code>string</diag_code>
         <tool></tool>
         <failed_test></failed_test>
         <value></value>
      </ont:SearchSolution>
   </soapenv:Body>
</soapenv:Envelope>

I began by trying some sample code of similar purposes with KSOAP2
such like this and it worked fine. And until now, I am trying to adapt
this code to my specific web-service using the WSDL file that I got.
As far as I understood, there are just some parameters and options to
change :

private static final String METHOD_NAME = "SearchSolution";
private static final String SOAP_ACTION = "http://myserver.com/
SearchSolution";
private static final String NAMESPACE   = "http://myserver.com";;
private static final String URL         = "http://myserver.com/
soap.php?WSDL&quot";

And here is the code I use to invoke my web service :

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); //set up
request
request.addProperty("manufacturer", "string");
request.addProperty("product_group", "string");
request.addProperty("product", "string");
request.addProperty("failure_appearance", "string");
request.addProperty("symptom_code", "");
request.addProperty("diag_code", "string");
request.addProperty("tool", "");
request.addProperty("failed_test", "");
request.addProperty("value", "");

//put all required data into a soap envelope
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);

Element h = new Element().createElement(NAMESPACE,
"AuthHeaderElement");
Element username = new Element().createElement(NAMESPACE, "username");
username.addChild(Node.TEXT, "username");
h.addChild(Node.ELEMENT, username);
Element pass = new Element().createElement(NAMESPACE, "password");
pass.addChild(Node.TEXT, "password");
h.addChild(Node.ELEMENT, pass);

Element[] security = new Element[1];
security[0] = h;
envelope.headerOut = security;
envelope.setOutputSoapObject(request);//prepare request

HttpTransportSE httpTransport = new HttpTransportSE(URL);

try {
httpTransport.call(SOAP_ACTION, envelope);
//send request
SoapObject result=(SoapObject)envelope.getResponse();
//get response
textView.setText("Status : "+result.toString());
} catch (IOException e) {
    e.printStackTrace();
} catch (XmlPullParserException e) {
    e.printStackTrace();
}

Unfortunately, I get the following error :

WARN/System.err(1129): org.xmlpull.v1.XmlPullParserException:
expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}
Envelope (position:START_TAG <html>@2:7 in
java.io.InputStreamReader@40532350)

I think that the problem is that the constants that I defined
(METHOD_NAME, SOAP_ACTION, NAMESPACE and URL) are may be wrong but I
don't know how to get the correct values. Does anybody know how to get
the correct values with just the WSDL file ? And could you please help
me if you see any other problem in my code ?

Thank you

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to