cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP header conventions - why does SoapUI create this header?

Highlighted
New Contributor

SOAP header conventions - why does SoapUI create this header?

SoapUI is smarter than me, and in the raw request, creates a header in my soap message that results in a successful submission.  I need to understand this.

 

I am using SoapUI to troubleshoot a webservice Java client.  The webservice client was generated using wsimport.exe to process a published WSDL file for the remote service.

 

My Java client was unable to submit the SOAP message without error, getting error messages that an Action header was missing.  In the trace output, I noticed that the Java client code did not generate any Header section in the SOAP message.  However, it did put the SOAP Action in the "Content-Type" http header of the http request.  This is what the Content-Type request header looks like:

 

Content-Type: application/soap+xml;charset="utf-8";action="http://www.fmcsa.dot.gov/schemas/FMCSA.ELD.Infrastructure/IELDSubmissionService/Submit"

 

I tried sending the same SOAP message using SoapUI.  It failed at first.  Then I copied the Content-Type http header from my Java trace output and manually created the Content-Type header in my SoapUI request.  Magically, it worked -- the message was accepted by the web service.  When I inspected the "raw" request in the SoapUI Raw tab, I noticed that SoapUI had actually created a header section in the SOAP message and put an Action element with the soap action as content.  Apparently the web service needs that header (although I don't see anything in the WSDL that calls for the header).  The raw soap message started as follows, with the new Header section:

 

<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">

<S:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://www.fmcsa.dot.gov/schemas/FMCSA.ELD.Infrast...>

</S:Header>

...

 

My question is:  Why did SoapUI look at the http Content-Type header, and decide to create that Header section and the Action element?  Is there some standard relating the two?  Furthermore, it turned an unsuccessful request into a successful one.  The answer to this may help me fix the Java client code to also be successful.

 

2 REPLIES 2
Highlighted
Community Hero

Re: SOAP header conventions - why does SoapUI create this header?

Hey @sb4,

If i understand correctly your original soap envelope didnt include a header tag in your envelope....is that right?

Ive always thought that the envelopes tags were mandatory so you have to have envelope, header and body tags in there as a minimum.

So your Content-Type header indicates its a soap message to your endpoint and so its expecting a header tag.

I "think" the 'operation' or 'operation name' tags in you wsdl is supposed to define this. This isnt necessarily true, its just what ive noticed when testing soap calls.

Does that help at all?

Cheers,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
New Contributor

Re: SOAP header conventions - why does SoapUI create this header?

Hi Rich, thanks for the reply.  I'm not sure, I think the SOAP Header is optional, and I only know of one way in a WSDL file to supposedly specify it.  The reference is here: https://www.ibm.com/developerworks/library/ws-tip-headers/index.html

 

(Aside: when I did my best to modify the WSDL file and add those elements referenced in the link, the "wsimport.exe" file seems to ignore my efforts and generates code that lacks the needed "Java Annotations" that ultimately should cause the JAXWS libraries to spit out the SOAP Header with the "Action" header block.  I proved those annotations do the job by adding them manually to the generated code, which is my current workaround for getting the SOAP message accepted at the endpoint.)

 

So it is still a mystery to me how SoapUI knows that a SOAP Header and Action header block is needed in the SOAP message, apparently by parsing the Content-Type HTTP header.  I am wondering if the WSDL is not really correct for the web service, or whether the web service should not mandate the SOAP Header, or if there is a bug in "wsimport.exe" that makes it fail to generate the correct Java code from the WSDL file.  I know that the SOAP 1.2 standard is used, but I can't tell so far if the WSDL file does or does not mandate the SOAP Header.  If I can get permission, I will post the WSDL file here.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors