Developing Asynchronous Web Services 4-13
helloServiceService = new HelloServiceService; HelloService helloService = helloServiceService.getHelloServicePort;
Get the request context to set the outgoing addressing properties WSBindingProvider wsbp = WSBindingProviderhelloService;
WSEndpointReference repl new WSEndpointReference
http:replace with the URL of the callback service, WS_ADDR_VER;
String uuid = uuid: + UUID.randomUUID; wsbp.setOutboundHeaders
new StringHeaderWS_ADDR_VER.messageIDTag, uuid, replyTo.createHeaderWS_ADDR_VER.replyToTag;
Add your code to call the desired methods. }
}
4.7.2 Updating the Callback Service Code
The following provides a sample of the callback service code. The code shown in bold illustrates how to extract the relatesToID from the message header, which is sent by the
client as the MessageID.
You need to implement the code to process the response and deploy the callback service as a Web service. Once deployed, add the URL of the callback service to the
client code as the replyTo field.
package async.jrf; import com.sun.xml.ws.api.addressing.AddressingVersion;
import com.sun.xml.ws.api.message.Header; import com.sun.xml.ws.api.message.HeaderList;
import com.sun.xml.ws.developer.JAXWSProperties; import javax.annotation.Resource;
import javax.jws.Oneway; import javax.jws.WebMethod;
import javax.jws.WebParam; import javax.jws.WebService;
import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style;
import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.ws.Action;
import javax.xml.ws.RequestWrapper; import javax.xml.ws.WebServiceContext;
import javax.xml.ws.soap.Addressing; THE CHANGES MADE TO THIS FILE WILL BE DESTROYED IF REGENERATED
This source file is generated by Oracle tools Contents may be subject to change
For reporting problems, use the following Version = Oracle WebServices 11.1.1.0.0, build 090303.0200.48673
WebServicetargetNamespace=http:jrf.async, name=HelloServiceResponse XmlSeeAlso
{ async.jrf.ObjectFactory.class } SOAPBindingstyle=Style.DOCUMENT
Addressingenabled=true, required=true public class HelloServiceResponseImpl
{ Resource
private WebServiceContext wsContext;
4-14 Concepts Guide for Oracle Infrastructure Web Services
private static final AddressingVersion WS_ADDR_VER = AddressingVersion.W3C; WebMethod
Actioninput= RequestWrapperlocalName=helloResponse,targetNamespace=http:jrf.async,
className=async.jrf.HelloResponse Oneway
public void helloResponseWebParamtargetNamespace=, name=return String _return
{ Use the sample code to extract the relatesTo id for correlation and then
add your rest of the logic System.out.printlnReceived the asynchronous reply;
get the messageId to correlate this reply with the original request HeaderList headerList =
HeaderListwsContext.getMessageContext.getJAXWSProperties.INBOUND_HEADER_LIST_ PROPERTY;
Header realtesToheader = headerList.getWS_ADDR_VER.relatesToTag, true; String relatesToMessageId = realtesToheader.getStringContent;
System.out.printlnRelatesTo message id: + relatesToMessageId; Add your implementation here.
} }
4.8 Attaching Policies to Asynchronous Web Services and Clients