Java EE Web Service client Quality report (iv)

Source: Internet
Author: User
Tags getmessage stub wsdl

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.