Http Post Problem

Hi,

I'm developing an Android application and ran into a problem while using the SendPostcardAndAddress method. I'm making http post requests to send postcards, without using the Postal Methods Java Toolkit, but for some reason I'm not able to get it working.

You can check out the url of the test http post request I make by accessing this text document:
httppost.txt

And the response I get after making the request:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <soap:Fault>
            <soap:Code>
                 <soap:Value>soap:Receiver</soap:Value>
            </soap:Code>
            <soap:Reason>
                <soap:Text xml:lang="en">Server was unable to process request. ---&gt; Data at the root level is invalid. Line 1, position 1.</soap:Text>
            </soap:Reason>
            <soap:Detail />
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

Any ideas what I might be doing wrong?

Let me know if you need more details.

Thanks,
Boti

Comments

Hi Boti, As you can see in

Hi Boti,

As you can see in some other threads in this forum, the reason for your problem is that we do not support HTTP POST requests for sending letters and postcards. These complex requests of string variables along with binary data is not supported by our server. You can use HTTP POST and GET for the simpler methods, such as GetStatus.

I've Googled some tutorials and discussions regarding using SOAP with Android but we have not tried it ourselves.

Thanks for the quick

Thanks for the quick response. It looks like I have to check out those SOAP requests after all.

Another quick question, now

Another quick question, now about the SOAP request...

I'm in the middle of implementing a request using the kSoap toolkit. To make a request and send it I need four variables which values I'm not sure of. This is what I use at the moment:

final String SOAP_ACTION = "PostalMethods/SendPostcardAndAddress";
final String METHOD_NAME = "SendPostcardAndAddress";
final String NAMESPACE = "https://api.postalmethods.com/2009-02-26";
final String URL = "https://api.postalmethods.com/2009-02-26/PostalWS.asmx";

I'm sure one the values is not correct because I always get a -4001 and the username is set. Just that I couldn't figure it out so far.

You can check this or this to see a sample of the toolkit in action.

Thanks again,
Boti

Try using the following

Try using the following values:

final String SOAP_ACTION = "PostalMethods/SendPostcardAndAddress";
final String METHOD_NAME = "SendPostcardAndAddress";
final String NAMESPACE = "PostalMethods";
final String URL = "https://api.postalmethods.com/2009-02-26/PostalWS.asmx";



If found the following description here.

   private static final String SOAP_ACTION = "http://tempuri.org/MethodName";
   private static final String METHOD_NAME = "MethodName";
   private static final String NAMESPACE = "http://tempuri.org/";
   private static final String URL = "http://192.168.2.200/Service.asmx";

All of the data above can be retrieved from the web service definition(WSDL).
METHOD_NAME is the name of the method that we define in the web service.
NAMESPACE is the namespace of the web service, default is “http://tempuri.org/”, can be specific to your own organization.
SOAP_ACTION is the direct concatenation of NAMESPACE followed by METHOD_NAME.
URL is the location where the web service can be accessed from. If the connection will be through SSL, you need to specify it here.(e.g. https)