views:

219

answers:

1

Using JAX-WS and a custom WSDL, is there a way to get the message that would be sent to a web-service without actually making a call to the service? I need to generate a soap message conforming to a WSDL, but that soap message is actually embedded into another message. I was thinking I could create a local web-service that just echos back the message but it seems like there should be a way without doing this or using a handlerchain when it doens't really matter that the message is sent.

Maybe the easiest thing to do is just to generate the soap manually?

A: 

maybe this example helps (from Understanding Web Services, Part 1: SOAP, IBM Developer Works, page 21):

MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();

SOAPPart SOAPPart = message.getSOAPPart();
SOAPEnvelope envelope = SOAPPart.getEnvelope();
SOAPBody body = envelope.getBody();

SOAPElement bodyElement = body.addChildElement(envelope.createName("echo", "req", "http://localhost:8080/axis2/services/MyService/"));

bodyElement.addChildElement("category").addTextNode("classifieds");
message.saveChanges();

SOAPPart SOAPpartbefore = message.getSOAPPart();
SOAPEnvelope reqenv = SOAPpartbefore.getEnvelope();

System.out.println(reqenv.toString());
Joaquín L. Robles