. Net calls the WebService encapsulated soapheader information released by Java xfire, Which is troublesome and needs to be changed to the proxy class.Code.
Java Server Verification Code
Package chachaba. map. service; import Org. codehaus. xfire. messagecontext; import Org. codehaus. xfire. handler. export acthandler; import Org. JDOM. element; public class authenticationhandler extends acthandler {public void invoke (messagecontext CFX) throws exception {If (CFX. getinmessage (). getheader () = NULL) {Throw new Org. codehaus. xfire. fault. xfirefault ("the request must contain verification information", org. codehaus. xfire. fault. xfirefault. sender);} element token = CFX. getinmessage (). getheader (). getchild ("authenticationtoken"); If (token = NULL) {Throw new Org. codehaus. xfire. fault. xfirefault ("the request must contain authentication information", org. codehaus. xfire. fault. xfirefault. sender);} string username = token. getchild ("username "). getvalue (); string Password = token. getchild ("password "). getvalue (); try {// for authentication, only the user of yw88 @ ccc0c325-fe67-4cad-baab-4ad9ebb4f927 is the authorized user if (username. equals ("yw88") & password. equals ("ccc0c325-fe67-4cad-baab-4ad9ebb4f927") // This statement does not display system. out. println ("authenticated"); else throw new exception ();} catch (exception e) {Throw new Org. codehaus. xfire. fault. xfirefault ("invalid user name and password", org. codehaus. xfire. fault. xfirefault. sender );}}}
The. NET call process is as follows:
1. Generate proxy classes, such as stallsservice. CS
2. Add a soapheader class to the proxy class. The complete code is as follows:
Public class authenticationtoken: soapheader {Public String username; Public String password ;}
3. Add soapheader class parameters to the proxy class,
Public authenticationtoken header = new authenticationtoken ();
4. Add the property code to the Method
[Soapheader ("Header")] public void deletter ter ([system. XML. serialization. xmlelementattribute (isnullable = true)] string in0) {This. invoke ("deleteinter", new object [] {in0 });}
5. Set the namespace in the proxy class to null,
[System. Web. Services. webservicebindingattribute (name = "stallsservicehttpbinding", namespace = "")]
6. The client call code is as follows:
Stallsservice client = new stallsservice (); authenticationtoken myheader = new authenticationtoken (); myheader. username = "username"; myheader. password = "password"; client. header = myheader; client. deletter ter ("9999 ");
OK