0

Ok, this has been driving me nuts all week, there has gotta be a simple explanation for why this happens. I have written a blackberry application that communicates with a SOAP ASP.NET 2.0 Web Service. The Web Service expects a SOAP Header in the request with a session token.

The SOAP Message is below:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
        <AuthenticationTicket xmlns="http://tempuri.org//">
            <DeviceId>c3a4fc48-ce59-43f0-ae48-3452b5df9f14</DeviceId>
            <UserId>00000000-0000-0000-0000-000000000000</UserId>
            <SessionId>F432F463D5A5613BDAFF1BB43264D40A20F691F397F7248F92424D5BE2E8A9DFC888C8418CEFEB84BA4A9FE203B02542C926B98D9C499389D91FE390D3D0D611EC2BC37BBE7AB21CA9533B9389075D417D5EDB82CB8D3E46680B17A6C9DE552CFBFBE86C84E96C20FB07BBCA373B456B8F2FDB9F711ADBA8DEF46222A96113559CEAB4AE41EA44B52BDEC1AAF5FA7598256859F60D1F5615AD35B47C5EA23D8019E0690C463330503D4F3026575BE04CE341D89A63770930569153D9523D6733C3B831C56824B94EFD696A83BB9C4DD93817BDCA299F20CD7CCEC479F6267A09A03AD3C025DBDEC3B8F49402DE1B6538</SessionId>
        </AuthenticationTicket>
    </soap:Header>
    <soap:Body>
        <Retrieve xmlns="https://mobile.southeasthealth.com/">
            <Request xsi:type="CallListRequest">
                <Type>CallList</Type>
                <DeviceId>00000000-0000-0000-0000-000000000000</DeviceId>
                <UserName>XXXX</UserName>
            </Request>
        </Retrieve>
    </soap:Body>
</soap:Envelope>

The code I am using to send the message is:

String url = app.getProtocol() + "://" + app.getHost() + (app.getPort() == 80 || app.getPort() == 443 ? "" : app.getPort()) + "/" + app.getService();

URL address = new URL(url);

TrustManagerManipulator.allowAllSsl();

URLConnection connection = address.openConnection();
HttpsURLConnection post = (HttpsURLConnection)connection;
post.setDoInput(true);
post.setDoOutput(true);
post.setRequestMethod("POST");
post.setRequestProperty("SOAPAction", app.getNamespace() + "/Retrieve");
post.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
post.setRequestProperty("Content-Length", String.valueOf(postData.toString().length()));
post.setReadTimeout(30000);

OutputStream outStream = post.getOutputStream();
Writer out = new OutputStreamWriter(outStream);
out.write(postData.toString());
out.flush();
out.close();

The problem I encounter is that when the request is received at the web service there is no SOAP Header contained in the message.

Has anyone else encountered this problem?

Many Thanks, in advance. Neil

----- UPDATE -----

I got it, I went back over the messages and compared these against the WSDL, I also ran the messages through SOAPUI, what through me was that the same code on Android worked with no problem.

I finally discovered that it came down to a namespace

<AuthenticationTicket xmlns="http://tempuri.org//">

The namespace above has two // at the end and this does not match the WSDL definition, I changed this to

<AuthenticationTicket xmlns="http://tempuri.org/">

And everything started working.

It would seem that Blackberry is a little more picky about valid SOAP than Android is.

I should have spotted that!!

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Neil Stevens
  • 3,534
  • 6
  • 42
  • 71
  • What libraries are you using for this? This doesn't look like BlackBerry Java to me. – Nate May 30 '13 at 11:57
  • Im using eclipse with the android and blackberry plugins, the app is originally an android app converted to blackberry using the Blackberry Plugin for Android – Neil Stevens May 30 '13 at 13:39
  • So, this is for BlackBerry-10? If so, you should use the BlackBerry-10 tag with your question, as this is completely different than legacy BlackBerry Java. – Nate May 30 '13 at 20:40

0 Answers0