Tomcat + ApacheSoap WebService deployed to the COM object

zhaozj2021-02-17  61

If you have used Microsoft's SOAPToolBox, you will know that you will be a very simple thing to deploy an access to COM objects. In the Java environment, it is not very complicated to complete this matter. The following is I access a simple COM object via WebService, with a simple SayHello method returns a string.

My environment is Tomcat 4.0 apachasoap, where tomcat is downloaded at http://jakarta.apache.org/site/binindex.html, and Apachesoap is downloaded at http://xml.apache.org/dist/soap/. step 1. Contain SOAP. JAR to ClassPath 2. Set the path where the comprovider.dll is located to PATH 3. VB Write a COM object code The following 'webdll.simath public function sayhello () AS STRING SAYHELLO = "Hello from object" End Function Compile Generate Webdll.dll 4. Write a deployment description file Webdll.xml Org.apache.soap.server.domfaultListener 5. Deploy Java Org.Apache.soap.server.serviceManagerClient http: // localhost: 8080 / soap / servlet / rpcrouter Deploy Webdll.xml 6.

Client program import java.io. *; import java.net. *; Import java.util. *; Import org.apache.soap. *; Import org.apache.soap.rpc. *; Public class jclient {public static Void main (string [] args) throws exception {integer n1 = null; integer n2 = null; final string URN = "URN: Webdll-com"; Vector params = new vector (); URL URL = New URL ("http: // " serverhost ": " serverport soapservlet); // Build the call Call call = new Call (); call.setTargetObjectURI (urn); call.setMethodName (." SayHello "); call.setEncodingStyleURI (Constants. NS_URI_SOAP_ENC); Call.SetParams (params); Response Resp = CALL.INVOKE (/ * router URL * / URL, / * ActionURI * / "); if (resp.generatedfault ()) {Fault Fault = Resp.GetFault ); System.out.println ("Ouch, The Call Failed:"); System.out.Println ("Fault Code =" Fault.GetFaultCode (); System.out.Println ("Fault String =" FAULT .getfaultstring ();} else {parameter results (); system.out.println;}}} static string serverhost = "L Ocalhost "; static string serverport =" 8080 "; static string soapservlet =" / soap / servlet / rpcrouter ";} // end addit 7. Test operation compile JClient boot Tomcat Run Java JClient Return Results Hello from object text Not properly, ZLYPERSON @ 163.net

转载请注明原文地址:https://www.9cbs.com/read-29358.html

New Post(0)