|
This is a good question, since the J2EE dynamic invocation interface (DII) client model allows access to an RPC-based Web service even if the details of the service are unknown prior to runtime. To create a DII client, follow these steps:
1: Create a Service object using the javax.xml.rpc.ServiceFactory class as follows:
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName(theServiceQName));
2: From the Service object, create a Call object as follows:
QName port = new QName(theQNnamePort);
Call call = service.createCall(port);
3: Set the service endpoint address on the Call object corresponding to the element of the WSDL file as follows:
call.setTargetEndpointAddress(theEndpointAddress);
4: Set the appropriate properties on the Call object.
5: Specify the method's return type, name, and parameter as follows:
QName qNameRetType = new QName(NS_XSD, "theXSDType");
call.setReturnType(qNameRetType);
call.setOperationName(new QName(theOperationNamespaceValue,
"theOperationName"));
call.addParameter("String_1", QNAME_TYPE_STRING,
ParameterMode.IN);
6: Invoke the remote method on the Call object as follows:
String[] params = { "param1" };
String result = (String)call.invoke(params);
Details for this scenario can be found at in the J2EE tutorial.
|