Client Service Packages
Client Service packages can be automatically generated by directing the WSDL compiler to the WSDL provided by the application server. This package contains many classes. The only class we need to modify is the client stub class. Similarly, the Server Web service package also contains the class tie, which binds Web service requests to the EJB method, and the client stub class is equipped with a method for each client of each service business method.
The name of the service Stub class is servantinterface_stub, where is the service name. Let's look at the Submitwork () method within the class Xactserviceservantinterface_stub:
/*
* Implementation of Submitwork
*/
public java.lang.String submitwork (java.lang.String string_1)
throws Java.rmi.RemoteException {
try {
streamingsenderstate _state = _start (_handlerchain);
internalsoapmessage _request = _state.getrequest ();
_request.setoperationcode (Submitwork_opcode);
xact.xactserviceservantinterface_submitwork_requeststruct
_myxactserviceservantinterface_submitwork_requeststruct =new Xact.xactserviceservantinterface_submitwork_ Requeststruct ();
_myxactserviceservantinterface_submitwork_requeststruct.setstring_1 (string_1);
soapblockinfo _bodyblock = new Soapblockinfo (ns1_submitwork_submitwork_qname);
_bodyblock.setvalue (_myxactserviceservantinterface_submitwork_requeststruct);
_bodyblock.setserializer (Myxactserviceservantinterface_submitwork_requeststruct_soapserializer);
_request.setbody (_bodyblock);
_state.getmessagecontext (). SetProperty (Httpclienttransport.http_soapaction_property, "");
Serializer.attachpendingreporttomessage (_state.getmessagecontext ());
_send ((String) _getproperty (Endpoint_address_property), _state);
xact.xactserviceservantinterface_submitwork_responsestruct
_myxactserviceservantinterface_submitwork_responsestruct = null;
Object _responseobj = _state.getresponse (). GetBody (). GetValue ();
if (_responseobj instanceof soapdeserializationstate) {
_myxactserviceservantinterface_submitwork_responsestruct =
(xact.xactserviceservantinterface_submitwork_responsestruct)
((soapdeserializationstate) _responseobj). getinstance ();
} else {
_myxactserviceservantinterface_submitwork_responsestruct = (xact.xactserviceservantinterface_submitwork_ responsestruct) Responseobj;
}
return _myxactserviceservantinterface_submitwork_responsestruct
. GetResult ();
} catch (RemoteException e) {
//Let this one through unchanged
throw E;
} catch (Jaxrpcexception e) {
throw new RemoteException (E.getmessage (), E);
} catch (Exception e) {
if (e instanceof runtimeexception) {
throw (runtimeexception) e;
} else {
throw new RemoteException (E.getmessage (), E);
}
}
}
In the above code, we added the following single line immediately before _send ():
Serializer.attachpendingreporttomessage (_state.getmessagecontext ());
If no unresolved client reports need to be sent, Attachpendingreporttomessage returns. Otherwise, it connects the current report to the XML and adds it to the SOAP message as a text attachment. We have made the same changes to other business methods, adding the above line of code immediately before each of their _send () calls.