cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP Adpater using HTTPURLConnection Java

Former Member
0 Kudos

I have been trying to communicate with a web service to send a SOAP message, web service is configured using XI SOAP Adapter (SAP) and i have the wsdl url. When i try to send my message over HTTP by providing my wsdl url and soapaction value from wsdl. I get 405 Method not allowed error. I am using Java's HTTPUrlConnection class to send my soap envelope. The same envelope is sent just fine using SOAPUI.


Moreover, wsdl has defined two ports, if i use the port url provided in wsdl directly, my message is sent just fine w/o any issue. If i open the port url connection in browser. It says Message Servlet OK and some other details about it.


My purpose is to communicate only using wsdl url and soapaction, as internal service endpoint location can be changed any time. So i should not rely on port url to communicate. Please take a look at the wsdl provided below. If possible advise. I think this might be issue due to Adapter is being used which is not accessible via soap action. Apologies for the bad english as i am not native.


<wsdl:portType name="SEND_REQUEST">
<wsdl:documentation/>
<wsdl:operation name="SEND_REQUEST">
<wsdl:documentation/>
<wsp:Policy>
<wsp:PolicyReference URI="#OP_SEND_REQUEST"/>
</wsp:Policy>
<wsdl:input message="p1:MT_DETAILS"/>
<wsdl:output message="p1:MT_RESPONSE"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SEND_REQUESTBinding" type="p1:SEND_REQUEST">
<soap:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SEND_REQUEST">
<soap:operation xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="http://sap.com/xi/WebService/soap1.1"/>
<wsdl:input>
<soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SEND_REQUESTService">
<wsdl:port name="Simple_Port" binding="p1:SEND_REQUESTBinding">
<soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="http://abc.local:7000/XISOAPAdapter/MessageServlet?[Some Properties here]"/>
</wsdl:port>
<wsdl:port name="Secure_Port" binding="p1:SEND_REQUESTBinding">
<soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="https://abc.local:7001/XISOAPAdapter/MessageServlet?[Some Properties here]"/>
</wsdl:port>
</wsdl:service>

Accepted Solutions (0)

Answers (1)

Answers (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Jawad,



My purpose is to communicate only using wsdl url and soapaction, as internal service endpoint location can be changed any time. So i should not rely on port url to communicate.

 <wsdl:portType name="SEND_REQUEST"><wsdl:documentation/><wsdl:operation name="SEND_REQUEST"><wsdl:documentation/><wsp:Policy><wsp:PolicyReference URI="#OP_SEND_REQUEST"/></wsp:Policy><wsdl:input message="p1:MT_DETAILS"/><wsdl:output message="p1:MT_RESPONSE"/></wsdl:operation></wsdl:portType><wsdl:binding name="SEND_REQUESTBinding" type="p1:SEND_REQUEST"><soap:binding xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" style="document" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="SEND_REQUEST"><soap:operation xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="http://sap.com/xi/WebService/soap1.1"/><wsdl:input><soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/></wsdl:input><wsdl:output><soap:body xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="SEND_REQUESTService"><wsdl:port name="Simple_Port" binding="p1:SEND_REQUESTBinding"><soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="http://abc.local:7000/XISOAPAdapter/MessageServlet?[Some Properties here]"/></wsdl:port><wsdl:port name="Secure_Port" binding="p1:SEND_REQUESTBinding"><soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="https://abc.local:7001/XISOAPAdapter/MessageServlet?[Some Properties here]"/></wsdl:port></wsdl:service>

The wsdl url is where you retrieve the wsdl. The wsdl port is where you actually post the message. This is actually the purpose of the wsdl port as stated in W3C standards. If you want to use the wsdl url, just remove the ?wsdl in it when you are using your program.

Regards,

Mark

Former Member
0 Kudos

Hi Mark,

Thanks for reaching out and answering to my question.

I agree with you that port is where we will be sending out our messages. My question was that,i was trying to reach the port by providing the SOAPACTION. So HTTPUrlConnection class will automatically reach out to binded port. In case my wsdl, soapAction="http://sap.com/xi/WebService/soap1.1", so when i set it as parameter, system throws an error (405 method not allowed).

Normally,if i provide a SOAPAction parameter (for other web service communications) and provide wsdl url, i can send my envelope fine. I think, this is some how related to implementation of SAP service.

If soapAction="http://sap.com/xi/WebService/soap1.1", does this means soapAction was not defined while creating the service ? Because i read somewhere in SAP docs that, this equivalent to empty soapAction.

I hope this makes sense.

Regards.

Jawad

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Jawad,

I tried creating a service interface with multiple operations and the SOAP action remained the same. So yes, it would seem that it is not defined at all.

Sorry but it seems you really have to use the port in your case.

Regards,

Mark