Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a webservice manually

 
Cobain Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I was figuring out what goes wrong with the generated Axis2 client code (as described here) I grabbed the packet containing the soap message and tried to use that in a ajax call



but I got a HTTP 500 error back.

500 The endpoint reference (EPR) for the Operation not found is /axis2/services/SimpleService?%3C?xml%20version=%221.0%22%20encoding=%22UTF-8%22?%3E%3Csoapenv:Envelope%20xmlns:soapenv=%22http://schemas.xmlsoap.org/soap/envelope/%22%3E%3Csoapenv:Body%3E%3Cns1:concatRequest%20xmlns:ns1=%22http://ttdev.com/ss%22%3E%3Cs1%3E%3C/s1%3E%3Cs2%3E%3C/s2%3E%3C/ns1:concatRequest%3E%3C/soapenv:Body%3E%3C/soapenv:Envelope%3E and the WSA Action = null


Then I took the soap message the Web Service Explorer used (or seemed to use) but it also didn't work with that.
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope><soapenv:Body><q0:concatRequest><s1>12</s1><s2>2312341234</s2></q0:concatRequest></soapenv:Body></soapenv:Envelope>

So how should the soap look like?

Here is my wsdl
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cobain,
You have provided detailed information to spot the problem!

You are missing the following two namespace declarations within soapenv:Envelope element of your SOAP message.
 
Cobain Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naren Chivukula wrote:You have provided detailed information to spot the problem!
But I missed to cross-link this thread in the previous. Thanks so far. I'll work on it tomorrow as I have to figure out, what's going on in the generated code. And because I'm still quite new to web services I'm very interested in how everything fits together and what's under the hood ;-)
 
Cobain Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, after hours of wondering why my packet sniffing tool didn't catch up the tcp stream from eclipse I figured out what exactly the Web Service Explorer in eclipse sends to the server.

Changing some parameters in my ajax call changed the http code from the previous 500 to 501 which was good somehow. With that information I know that some headers must be missing. The monitored tcp stream looked like:


POST /axis2/services/SimpleService/ HTTP/1.1
Host: 127.0.0.1:8080
Content-Type: text/xml; charset=utf-8
Content-Length: 325
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: IBM Web Services Explorer
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "http://ttdev.com/ss/NewOperation"
Connection: close

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://ttdev.com/ss" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:concatRequest>
<s1>asdf</s1>
<s2>1234</s2>
</q0:concatRequest>
</soapenv:Body>
</soapenv:Envelope>
HTTP/1.1 200 OK
Date: Wed, 12 Jan 2011 15:06:51 GMT
Server: Simple-Server/1.1
Transfer-Encoding: chunked
Content-Type: text/xml; charset=utf-8
Connection: close

d1
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:concatResponse xmlns:ns1="http://ttdev.com/ss">asdf1234</ns1:concatResponse>
22
</soapenv:Body></soapenv:Envelope>
0


Aha, the SOAPAction was missing and the contentType wasn't set to application/soap+xml (but application/xml should also work as soap is xml). I don't know what d1 and the latter 0 means, maybe there's something wrong with the encoding (in my packet sniffer). The corresponding symbols with these hex codes don't make any sense. But as the server is responding back correctly those symbols seem to have no impact.

I'll post the ajax call very soon for those who are interested in that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic