Finally, in the study of GWT, we need to use the. NET WebService.CodeThere are many problems.
To call. Net WebService in Java, an axis package is required. Download the package and reference it.
When referencing, you need to pay attention to some minor issues.
Java end
Public String servicelogon (string user, string PWD) throws serviceexception <br/>{< br/> string url = "http: // localhost/WebServices/service. asmx "; <br/> service = new service (); <br/> call = (CALL) service. createcall (); <br/> // We Have To figure our The namespace. the Java doesn' t know where is the namespace <br/> call. setoperationname (New QNAME ("http: // localhost/WebServices/service. asmx "," Logon "); </P> <p> call. addparameter (New QNAME ("http: // localhost/WebServices/service. asmx "," username "), xmltype. xsd_string, javax. XML. RPC. parametermode. in); <br/> call. addparameter (New QNAME ("http: // localhost/WebServices/service. asmx "," password "), xmltype. xsd_string, javax. XML. RPC. parametermode. in); <br/> string res = ""; <br/> try {<br/> call. settargetendpointaddress (new URL ("http: // localhost/WebServices/service. asmx "); <br/> res = (string) Call. invoke (new object [] {user, PWD}); <br/>} catch (malformedurlexception E) {<br/> // todo auto-generated Catch Block <br/> E. printstacktrace (); <br/>} catch (RemoteException e) {<br/> // todo auto-generated Catch Block <br/> E. printstacktrace (); <br/>}< br/> return res; <br/>}< br/>
One small problem that needs to be noted is that when referencing, we should point out the namespace of. Net WebService. Different Code namespaces are different.
When adding parameters, you must generate a new QNAME.
Call. addparameter (New QNAME ("http: // localhost/WebServices/service. asmx "," username "), xmltype. xsd_string, javax. XML. RPC. parametermode. in); if it is not new, the received parameter will be null.
. Net end.
Using system; <br/> using system. web; <br/> using system. web. services; <br/> using system. web. services. protocols; <br/> [WebService (namespace = "http: // localhost/WebServices/service. asmx ")] // namespace <br/> [soapdocumentservice (routingstyle = soapserviceroutingstyle. requestelement)] // very import must figure out <br/> public class service: system. web. services. webService <br/> {<br/> Public Service () {<br/> // uncomment the following line if using designed components <br/>/initializecomponent (); <br/>}< br/> [webmethod] <br/> Public String helloworld () {<br/> return "Hello World "; <br/>}< br/> [webmethod] <br/> Public String Logon (string username, string password) <br/> {<br/> If (username = "Steven _wang" & Password = "123123") <br/> return "Welcome to Asp.net WebService "; <br/> else <br/> return "username:" + username + ", password:" + password; <br/>}</P> <p >}< br/>
This code is available in vs2005 framework2.0, windowxp, iis5.0
Jdk1.6, eclipse3.3, axis1.4
Debugging is successful.