This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Web Services and the fly likes Adding Header Information Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "Adding Header Information" Watch "Adding Header Information" New topic
Author

Adding Header Information

Dave Trower
Ranch Hand

Joined: Feb 12, 2003
Posts: 78
I just started working with Web Services. I was able to create stubs from the WSDL and send out a SOAP request and got a reply back.
My questions is, can I continue to use the java stubs and add a header to the SOAP request? Is there a way to somehow import the request that comes from the stub into SAAJ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
I'm not quite clear on what you're trying to do, but this example SAAJ client sets both HTTP headers and SOAP headers.


Android appsImageJ pluginsJava web charts
Dave Trower
Ranch Hand

Joined: Feb 12, 2003
Posts: 78
I did not explain what I was asking very well.
Here is the code I am currently using in a proof-of-concept test:
Class collinClass = com.alltel.AlltelEAL_Collin_PortType.class;
//Create the service
AlltelEAL_Collin_Service_Impl collinService = new AlltelEAL_Collin_Service_Impl();
//create port
AlltelEAL_Collin_PortType port = (AlltelEAL_Collin_PortType) collinService.getPort(collinClass);
AccountLookupResponseType ealResponse = port.accountLookupPOC("M","5015550952");
CustomerInfo custInfo = ealResponse.getCustomerInfo();
String lastName = custInfo.getLastName();
String firstName = custInfo.getFirstName();
System.out.println("Customer's first name is " + firstName);
System.out.println("Customer's last name is " + lastName);

Here a serch is done on the phone number 5015550952 and the first and
last name is retrieved.
Here I created stub classes from the WSDL.
I like this approach since I would like to avoid creating the XML by hand if I can.
The problem I have is when this code goes to production, we need to create a header that contains a digital signiture.
What I want to do is continue to use the stubs but I need to use something like SAAJ to add the header.
Can this be done or I am approaching the problem the wrong way?
Thank you in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
The usual way to add digital signatures is to use the WS-Security standard that is implemented by the WSS4J library. I've only ever used WSS4J for username/password authentication, though, not signatures, so I can't help in this regard.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Typically headers are processed by handlers - i.e. the client side request handler would generate and add the header to the request, the server request handler would verify it (or fault the message)
Supporting Digital Signatures Within SOAP Messages
A how-to guide for supporting digital signatures within SOAP messages, part 3
Note that accepted headers can be identified within the WSDL - the request headers appear as bound input messages (i.e. in the binding element) but are not referenced in the portType element. The stub will have no reference to the headers as it only represents the portType interface. This is why handlers are responsible for processing headers - not the stub.
[ June 18, 2007: Message edited by: Peer Reynders ]

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Adding Header Information
 
Similar Threads
setting namespaces in SOAP request payload from a java client
One more question about SOAP
SOAP header in SOAP request
Retrieve Soap header
Including information in the SOAP header in a web service invocation.