vect
vect

Reputation: 665

JBossWS doesn't recognize WS-A header

I have a web-service stub implemented with JAX-WS and deployed on JBossAS 7. Here is a source code:

package org.mycompany.adapters.ws;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.soap.Addressing;

@WebService
@Addressing(enabled = true, required = true)
public class AdapterSessionManager {

    @WebMethod
    public String initAdapterSession() {
        return "hello";
    }
}

Here is a WSDL generated by JBoss for this web-service:

<wsdl:definitions name="AdapterSessionManagerService" targetNamespace="http://ws.adapters.mycompany.org/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.adapters.mycompany.org/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <wsdl:types>
      <xs:schema elementFormDefault="unqualified" targetNamespace="http://ws.adapters.mycompany.org/" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
         <xs:element name="initAdapterSession" type="tns:initAdapterSession"/>
         <xs:element name="initAdapterSessionResponse" type="tns:initAdapterSessionResponse"/>
         <xs:complexType name="initAdapterSession">
            <xs:sequence/>
         </xs:complexType>
         <xs:complexType name="initAdapterSessionResponse">
            <xs:sequence>
               <xs:element minOccurs="0" name="return" type="xs:string"/>
            </xs:sequence>
         </xs:complexType>
      </xs:schema>
   </wsdl:types>
   <wsdl:message name="initAdapterSessionResponse">
      <wsdl:part element="tns:initAdapterSessionResponse" name="parameters"/>
   </wsdl:message>
   <wsdl:message name="initAdapterSession">
      <wsdl:part element="tns:initAdapterSession" name="parameters"/>
   </wsdl:message>
   <wsdl:portType name="AdapterSessionManager">
      <wsdl:operation name="initAdapterSession">
         <wsdl:input message="tns:initAdapterSession" name="initAdapterSession" wsam:Action="http://ws.adapters.mycompany.org/AdapterSessionManager/initAdapterSessionRequest" wsaw:Action="http://ws.adapters.mycompany.org/AdapterSessionManager/initAdapterSessionRequest"/>
         <wsdl:output message="tns:initAdapterSessionResponse" name="initAdapterSessionResponse" wsam:Action="http://ws.adapters.mycompany.org/AdapterSessionManager/initAdapterSessionResponse" wsaw:Action="http://ws.adapters.mycompany.org/AdapterSessionManager/initAdapterSessionResponse"/>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="AdapterSessionManagerServiceSoapBinding" type="tns:AdapterSessionManager">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsaw:UsingAddressing wsdl:required="true"/>
      <wsp:PolicyReference URI="#AdapterSessionManagerServiceSoapBinding_WSAM_Addressing_Policy"/>
      <wsdl:operation name="initAdapterSession">
         <soap:operation soapAction="" style="document"/>
         <wsdl:input name="initAdapterSession">
            <soap:body use="literal"/>
         </wsdl:input>
         <wsdl:output name="initAdapterSessionResponse">
            <soap:body use="literal"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="AdapterSessionManagerService">
      <wsdl:port binding="tns:AdapterSessionManagerServiceSoapBinding" name="AdapterSessionManagerPort">
         <soap:address location="http://localhost:8081/adapters/AdapterSessionManager"/>
      </wsdl:port>
   </wsdl:service>
   <wsp:Policy wsu:Id="AdapterSessionManagerServiceSoapBinding_WSAM_Addressing_Policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <wsam:Addressing>
         <wsp:Policy/>
      </wsam:Addressing>
   </wsp:Policy>
</wsdl:definitions>

When I try to invoke initAdapterSession with the following SOAP-request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.adapters.mycompany.org/">
   <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
      <wsa:Action>http://ws.adapters.mycompany.org/AdapterSessionManager/initAdapterSessionRequest</wsa:Action>
   </soapenv:Header>
   <soapenv:Body>
      <ws:initAdapterSession/>
   </soapenv:Body>
</soapenv:Envelope>

"A required header representing a Message Addressing Property is not present" SOAP fault occurs:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
      <Action xmlns="http://www.w3.org/2005/08/addressing">http://ws.adapters.mycompany.org/AdapterSessionManager/initAdapterSession/Fault/SoapFault</Action>
      <MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:d5b5c6aa-fd66-49bd-b928-488fa8e07f7b</MessageID>
      <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/unspecified</RelatesTo>
   </soap:Header>
   <soap:Body>
      <soap:Fault>
         <faultcode xmlns:ns1="http://www.w3.org/2005/08/addressing">ns1:MessageAddressingHeaderRequired</faultcode>
         <faultstring>A required header representing a Message Addressing Property is not present</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

The SOAP-request is sent by soapUI. All WS-A options in soapUI preferences (WS-A settings tab) are disabled. Enable WS-A addressing checkbox in request settings is switched off too. Actually the same error occurs even when all these options are enabled.

Why JBoss doesn't see WS-A header within the request?

Upvotes: 0

Views: 1738

Answers (2)

vect
vect

Reputation: 665

Just found lacking header. The fault doesn't arise if wsa:MessageID is passed with a SOAP-request. In my opinion it's a weird behavior, given that the wsa:MessageID is described as an optional header in WS-A 1.0 specification.

Upvotes: 0

Nick Roth
Nick Roth

Reputation: 3077

The SOAP fault "A required header representing a Message Addressing Property is not present" happens when a SOAP message does not have all the required WS-Addressing header information. It's not a JBoss specific exception, I've had this happen to me on WebSphere as well.

Your request only shows that it's sending the Action header. Looking at the spec (http://www.w3.org/Submission/ws-addressing/#_Toc77464323) it seems you need to send both the Action and To headers. The other option is to not send any WS-Addressing headers at all, but I would guess that, based on your WSDL, the server may not accept messages without WS-Addressing.

Upvotes: 1

Related Questions