Community

how to set headers in JAX-WS

reply from Neil McFarlane in JBoss Web Services - View the full discussion

Sorry to drag up an old message like this, but I don't see a newer one on the same topic.

Are the three solutions presented still the only way of handling  authenication via headers within the operation.  For example, a WSDL I'm trying to build a client for has the following:

{code:xml}<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://ws.myWebService.net" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://ws.myWebService.net" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://ws.myWebService.net">
      <s:element name="myOperation">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="1" maxOccurs="1" name="isSecureMode" type="s:boolean" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="myOperationResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="myOperationResult" type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="AuthenticationXML" type="tns:AuthenticationXML" />
      <s:complexType name="AuthenticationXML">
        <s:sequence>
          <s:element minOccurs="0" maxOccurs="1" name="User" type="s:string" />
          <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
        </s:sequence>
        <s:anyAttribute />
      </s:complexType>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="myOperationSoapIn">
    <wsdl:part name="parameters" element="tns:myOperation" />
  </wsdl:message>
  <wsdl:message name="myOperationSoapOut">
    <wsdl:part name="parameters" element="tns:myOperationResponse" />
  </wsdl:message>
  <wsdl:message name="myOperationAuthenticationXML">
    <wsdl:part name="AuthenticationXML" element="tns:AuthenticationXML" />
  </wsdl:message>
  <wsdl:message name="SendDataAuthenticationXML">
    <wsdl:part name="AuthenticationXML" element="tns:AuthenticationXML" />
  </wsdl:message>
<wsdl:portType name="myPort">
  <wsdl:operation name="myOperation">
   <wsdl:input message="tns:myOperationSoapIn" />
   <wsdl:output message="tns:myOperationSoapOut" />
  </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="myPort12" type="tns:myPort">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="myOperation">
      <soap12:operation soapAction="myWebService:myOperation" style="document" />
      <wsdl:input>
        <soap12:body use="literal" />
        <soap12:header message="tns:myOperationAuthenticationXML" part="AuthenticationXML" use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="myWebServiceWS">
    <wsdl:port name="myPort11" binding="tns:myPort11">
      <soap:address location="https://devws.myWebService.myDomain.net/myWebServicews/myWebServicews.asmx" />
    </wsdl:port>
    <wsdl:port name="myPort12" binding="tns:myPort12">
      <soap12:address location="https://devws.myWebService.myDomain.net/myWebServicews/myWebServicews.asmx" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>{code}

With WsConsume, I don't get the option to add Authentication elements to my methods and setting the binding properties does nothing.

Reply to this message by going to Community

Start a new discussion in JBoss Web Services at Community