• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Basic SOAP Header Question

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm new to Web Services and usually run some demo code to understand what actually is going there (it helps me in understanding the tutorials easily).

I had successfully tested 'hello' example on axis ref:
http://www.javaranch.com/newsletter/May2002/newslettermay2002.jsp#axis .

It says:

String endpoint = "http://localhost:" + options.getPort() +
"/axis/Hello.jws";

call.setOperationName("greet");
call.addParameter("name", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
String msg = (String)call.invoke(new Object[] {args[0]});
System.out.println("Reply: " + msg);

converts to:

<ns1:greet xmlns:ns1="http://localhost:8080/axis/Hello.jws">
<name xsi:type="xsd:string">Greg</name>
</ns1:greet>

its ok..!!

but i want to know, how to add soap header values to our request and response custome code?

like:
Request:

<SOAP-ENV:Header>
<ClientID>abc123</ClientID>
<AccountType xsi:type="xsd:string">Credit</AccountType>
</SOAP-ENV:Header>


Response:
<SOAP-ENV:Header>
<TransactionID>TX000123</TransactionID>
</SOAP-ENV:Header>

thanks.
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An easy way to send out a SOAP message with header is:

Note: Modify the header and body per your requirement. Above source is from samples/message/TestMsg.java in axis samples).

At the service end you will need message handlers (refer axis samples/echo/echoHeaderStringHandler.java) which can process both soap request and response to produce the required header in the response soap message.

At the client you can read the response header as follows:

MessageContext mc = call.getMessageContext();
Vector headerVec = mc.getResponseMessage().getSOAPEnvelope().getHeaders();
You can explore further on these lines.

~Watsh
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic