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?
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.
Joined: Mar 22, 2005
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.
Joined: Aug 19, 2005
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 ]