Stuff below is from

http://download.oracle.com/javaee/5/tutorial/doc/bnbhr.html#bnbih

 

my own comment:

they describe how to create a message and how to get the envelop from the 
message and how to get the header and the body-part from the envelop!

 

@WebParam  adds Parameters for your @WebService@WebMethod!

While

A SOAP-header is a parameter for the axis2 or other web service engine, not for 
your webservice-method!

 

Unfortunately I have not found any Annotations about how to massage a SOAP 
Header in the SAAJ JAX-WS Specs!  

 

So we need to get and massage the headers differently.

 

you should add some code to your method to massage a header prior to send to 
server or send to client.

 

Keep in mind that header attributes between SOAP 11 and SOAP 12 are not the 
same!

 

Josef

 

 

Adding Content to the Header

To add content to the header, you create a SOAPHeaderElement object. As with 
all new elements, it must have an associated QName object.

For example, suppose you want to add a conformance claim header to the message 
to state that your message conforms to the WS-I Basic Profile. The following 
code fragment retrieves the SOAPHeader object from message and adds a new 
SOAPHeaderElement object to it. This SOAPHeaderElement object contains the 
correct qualified name and attribute for a WS-I conformance claim header.

 

SOAPHeader header = message.getSOAPHeader();

QName headerName = new QName("http://ws-i.org/schemas/conformanceClaim/";,

    "Claim", "wsi");

SOAPHeaderElement headerElement =

    header.addHeaderElement(headerName);

headerElement.addAttribute(new QName("conformsTo"),

    "http://ws-i.org/profiles/basic/1.1/";);

 

At this point, header contains the SOAPHeaderElement object headerElement 
identified by the QName object headerName. Note that the addHeaderElement 
method both creates headerElement and adds it to header. A conformance claim 
header has no content. This code produces the following XML header:

 

<SOAP-ENV:Header>

  <wsi:Claim

    xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/";

    conformsTo="http://ws-i.org/profiles/basic/1.1/"/>

</SOAP-ENV:Header>

 

For more information about creating SOAP messages that conform to WS-I, see the 
Conformance Claim Attachment Mechanisms document described in the Conformance 
section of the WS-I Basic Profile 
<http://www.ws-i.org/Profiles/BasicProfile-1.1.html#conformance> . For a 
different kind of header, you might want to add content to headerElement. The 
following line of code uses the method addTextNode to do this. 
headerElement.addTextNode("order");

Now you have the SOAPHeader object header that contains a SOAPHeaderElement 
object whose content is "order".

 

 

Von: André Lemos [mailto:ale...@critical-health.com] 
Gesendet: Montag, 27. Juni 2011 18:32
An: java-user@axis.apache.org
Betreff: Problem with header annotations - axis 1.6.0

 

Hi,

 

 

I'm having some trouble using the echoString used on the unitary tests. 

 

I've created a class with:

 

       @WebMethod

       @WebResult(name = "headerReturn", header = true)

       public String echoString(

                    @WebParam(name = "renamedParam1", header = true) String 
param1,

                    @WebParam(header = true) String param2,

                    @WebParam(targetNamespace = "webparam.namespace", header = 
true) String param3,

                    @WebParam(mode = WebParam.Mode.OUT, header = true) 
Holder<String> outOnly,

                    @WebParam(name = "inOut", mode = WebParam.Mode.INOUT, 
header = true) Holder<String> inOut,

                    String notInHeader) {

             String headerReturn = param2;

             return headerReturn;

       }

 

 

inside, but instead of getting something on my <soap:Header>, I get this:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:wsdl="http://wsdl.patients.vitalsen.critical.pt 
<http://wsdl.patients.vitalsen.critical.pt/> ">

   <soapenv:Header/>

   <soapenv:Body>

      <wsdl:echoString>

         <!--Optional:-->

         <renamedParam1>?</renamedParam1>

         <!--Optional:-->

         <param2>?</param2>

         <!--Optional:-->

         <param3>?</param3>

         <!--Zero or more repetitions:-->

         <outOnly>?</outOnly>

         <!--Zero or more repetitions:-->

         <inOut>?</inOut>

         <!--Optional:-->

         <notInHeader>?</notInHeader>

      </wsdl:echoString>

   </soapenv:Body>

</soapenv:Envelope>

 

 

what am I doing wrong?

 

 

 

Ps.: could you reply directly? not enrolled on the mailing-list.

 

 

Thanks,

 

André Lemos

Reply via email to