Soap Request problem

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Soap Request problem

Postby tobias123 » Sat May 29, 2010 12:37 pm

hello

My code looks like this:


Code: Select all
private static final String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
    private static final String METHOD_NAME = "CelsiusToFahrenheit";
    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
    TextView tv;
    @Override
   
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv = (TextView) findViewById(R.id.TextView01);
       
        SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
        Request.addProperty("Celsius", "10");
        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet = true;
        soapEnvelope.setOutputSoapObject(Request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        try {
         androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
      } catch (IOException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
      } catch (XmlPullParserException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
      }
        Object result;
      try {
         result = soapEnvelope.getResponse();
      } catch (SoapFault e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();


In wireshark I see the http Request and Response.
The Request looks like this:
0200 3c 6e 30 3a 43 65 6c 73 69 75 73 54 6f 46 61 68 <n0:Cels iusToFah
0210 72 65 6e 68 65 69 74 20 69 64 3d 22 6f 30 22 20 renheit id="o0"
0220 63 3a 72 6f 6f 74 3d 22 31 22 20 78 6d 6c 6e 73 c:root=" 1" xmlns
0230 3a 6e 30 3d 22 68 74 74 70 3a 2f 2f 74 65 6d 70 :n0="htt p://temp
0240 75 72 69 2e 6f 72 67 2f 22 3e 3c 43 65 6c 73 69 uri.org/ "><Celsi
0250 75 73 20 69 3a 74 79 70 65 3d 22 64 3a 73 74 72 us i:typ e="d:str
0260 69 6e 67 22 3e 31 30 3c 2f 43 65 6c 73 69 75 73 ing">10< /Celsius
0270 3e 3c 2f 6e 30 3a 43 65 6c 73 69 75 73 54 6f 46 ></n0:Ce lsiusToF
0280 61 68 72 65 6e 68 65 69 74 3e 3c 2f 76 3a 42 6f ahrenhei t></v:Bo
0290 64 79 3e 3c 2f 76 3a 45 6e 76 65 6c 6f 70 65 3e dy></v:E nvelope>

And there is the problem: this :n0 in the CelsiusToFahrenheit tag.
So the Server gives me an Error in the <celsius>ERROR</celsius> back

the request should look like this:
0200 3c 43 65 6c 73 69 75 73 54 6f 46 61 68 72 65 6e <Celsius ToFahren
0210 68 65 69 74 20 78 6d 6c 6e 73 3d 22 68 74 74 70 heit xml ns="http
0220 3a 2f 2f 74 65 6d 70 75 72 69 2e 6f 72 67 2f 22 ://tempu ri.org/"
0230 20 69 64 3d 22 6f 30 22 20 63 3a 72 6f 6f 74 3d id="o0" c:root=
0240 22 31 22 3e 3c 43 65 6c 73 69 75 73 20 69 3a 74 "1"><Cel sius i:t
0250 79 70 65 3d 22 64 3a 73 74 72 69 6e 67 22 3e 35 ype="d:s tring">5
0260 35 3c 2f 43 65 6c 73 69 75 73 3e 3c 2f 43 65 6c 5</Celsi us></Cel
0270 73 69 75 73 54 6f 46 61 68 72 65 6e 68 65 69 74 siusToFa hrenheit
0280 3e 3c 2f 76 3a 42 6f 64 79 3e 3c 2f 76 3a 45 6e ></v:Bod y></v:En
0290 76 65 6c 6f 70 65 3e 0d 0a velope>. .

What can I do?

Thx for help!
tobias123
Freshman
Freshman
 
Posts: 3
Joined: Wed May 26, 2010 9:00 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 8 guests