Server did not recognize the value of HTTP Header SOAPAction: .

2,249 views
Skip to first unread message

Lucio Crusca

unread,
Jan 18, 2011, 6:34:24 AM1/18/11
to ksoap2-...@googlegroups.com
Hi there, me again.

Please ignore my previous message about how to add the ksoap2-android library, I've finally managed to do that. Now the real problems start... I have to consume these webservices:

http://www.robedikappa.net/storelocatorWS/storelocator.asmx?WSDL

and here is my test code:

package com.virtual_bit.storelocator;

import java.io.IOException;
import java.util.*

import android.app.Activity;
import android.os.Bundle;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

public class StoreLocator extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        consumeWS();
    }

    private void consumeWS()
    {
        SoapSerializationEnvelope sse = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
        SoapObject request = new SoapObject("http://tempuri.org/", "GetRegioni");
        sse.setOutputSoapObject(request);

        HttpTransportSE htpse = new HttpTransportSE("http://www.robedikappa.net/storelocatorWS/storelocator.asmx");
        try
        {
           htpse.call("", sse);
        }
        catch (Exception e)
        {
           e.printStackTrace();
        }
        System.out.println(sse.bodyIn.toString());
        SoapObject replyBody = (SoapObject)sse.bodyIn;
        Vector regioni = (Vector)replyBody.getProperty(0);
        for (Iterator iterator = regioni.iterator(); iterator.hasNext();)
        {
           Object object = (Object) iterator.next();
           System.out.println(object.toString());
        } 
    }
}
 
 However when I debug it and set a breakpoint at

        System.out.println(sse.bodyIn.toString());

I see sse.bodyIn is actually a SoapFault instance with faultString containing:

"Server did not recognize the value of HTTP Header SOAPAction: ."

Does that mean I specified a single dot as SOAPAction? Or is the dot appended to the logs as fullstop and the SOAPAction is empty? How can I set a meaningful SOAPAction? Do I ever need to do that?

I've altrady tried the following things:
  1. SoapSerializationEnvelope.VER11 instead of SoapSerializationEnvelope.VER12 (which resulted in bodyIn being null)
  2. Calling the webservice with a "normal" java application automatically generated by Netbeans from the WSDL, and it worked (just to be sure the server is working as it should).
Can you please help me spot my mistake?

Manfred Moser

unread,
Jan 18, 2011, 12:28:14 PM1/18/11
to ksoap2-...@googlegroups.com
You should use getResponse() after the call and see if the repsonseBody is as requested. Also check out the wiki tips and tricks and confirm that the request and reponse are as they should be.. 

manfred

CJGarber

unread,
Jan 18, 2011, 12:52:50 PM1/18/11
to ksoap2-android

I am new to ksoap as well, but shouldn't the first parameter in
htpse.call("", sse) be set to the SOAPAction (eg a concatenation of
the namespace and method name)?
The error message you are getting seems to be complaining about an
empty string for the SOAPAction....

Manfred Moser

unread,
Jan 18, 2011, 12:54:41 PM1/18/11
to ksoap2-...@googlegroups.com
Thats correct too ;-) Nice spotting.

saber salehi

unread,
Apr 28, 2013, 7:02:32 AM4/28/13
to ksoap2-...@googlegroups.com
use the following code instead of your code, I hope be useful for u

         private static final String METHOD_NAMEREGIONI = "GetRegioni";
private static final String SOAP_ACTION = "http://tempuri.org/GetRegioni";
private static final String NAMESPACE = "http://tempuri.org/";

public void fCallRegioni(){

try {
// SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAMEREGIONI);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);

if (envelope.bodyIn instanceof SoapObject) { // SoapObject = SUCCESS
SoapObject vSoapObject = (SoapObject) envelope.bodyIn;
int vCount = vSoapObject.getPropertyCount();
System.out.println("count: " + vCount);
// T processedResponse = parseSOAPResponse(soapObject);
// ... do whatever you want with this object now
} else if (envelope.bodyIn instanceof SoapFault) { // SoapFault =
// FAILURE
SoapFault soapFault = (SoapFault) envelope.bodyIn;
throw new Exception(soapFault.getMessage());
}
Object result = (Object) envelope.getResponse();
} catch (Exception e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
String re = errors.toString();
System.out.println(re);
Reply all
Reply to author
Forward
0 new messages