Loading ...
Sorry, an error occurred while loading the content.
 

MSSOAP and apache client

Expand Messages
  • ashutosh_kumar_sinha@yahoo.com
    Hi , I am trying to access some COM objects and methods from apache java client using a MSSOAP server. The MSSOAP was set us using a WSDL wizard to point to a
    Message 1 of 1 , Jul 31, 2001
      Hi ,

      I am trying to access some COM objects and methods from apache
      java client using a MSSOAP server. The MSSOAP was set us using a WSDL
      wizard to point to a simple calc object which comes as an example. I
      used following java code tpo connect to this object

      import java.net.*;
      import java.util.*;
      import org.apache.soap.*;
      import org.apache.soap.encoding.*;
      import org.apache.soap.encoding.soapenc.*;
      import org.apache.soap.SOAPException;
      import org.apache.soap.Constants;
      import org.apache.soap.Fault;
      import org.apache.soap.rpc.Call;
      import org.apache.soap.util.xml.*;
      import org.apache.soap.rpc.Parameter;
      import org.apache.soap.rpc.Response;
      import org.apache.soap.rpc.RPCMessage;


      /**
      *
      * @author cb2712
      * @version
      */
      public class ms_1 extends java.lang.Object {

      /**
      * @param args the command line arguments
      */


      public static void main (String args[]) {
      String strLocation = "";

      Response oResp = null;

      //Start optional proxy server code
      //String strProxyHost = null;
      //int intProxyPort = -1;
      //SOAPHTTPConnection oHTTPConn = new SOAPHTTPConnection();
      //if (strProxyHost != null) {
      //oHTTPConn.setProxyHost(strProxyHost);
      //oHTTPConn.setProxyPort(intProxyPort);
      // }
      //End optional proxy server code

      // Build the call.
      Call oCall = new Call();
      //oCall.setSOAPTransport(oHTTPConn);

      //SOAPMappingRegistry oSOAPMap = new SOAPMappingRegistry ();
      //StringDeserializer oStrDeserial = new StringDeserializer ();
      //oSOAPMap.mapTypes (Constants.NS_URI_SOAP_ENC, new QName ("",
      "Result"), null, null, oStrDeserial);
      //oCall.setSOAPMappingRegistry (oSOAPMap);
      oCall.setEncodingStyleURI ("Constants.NS_URI_SOAP_ENC");
      //oCall.setTargetObjectURI("http://tempuri.org/type"); // ???
      XML SCHEMA FOR TARGET OBJECT ??? ASHUTOSH
      oCall.setTargetObjectURI("Calc");

      //Set the method name to call
      oCall.setMethodName("Add");

      //Set the parameters
      Vector oParIn = new Vector();
      oParIn.addElement(new Parameter("A", Double.class,new
      Double("12"), Constants.NS_URI_SOAP_ENC));
      oParIn.addElement(new Parameter("B", Double.class,new
      Double("15"), Constants.NS_URI_SOAP_ENC));

      //Set the end point, service URL
      String strServiceURL = new String
      ("http://f2-paristest-1/MsSoapSamples/Calc/Service/Rpc/AspJsVb/calc.as
      p");
      //String strServiceURL = new String ("http://www.yahoo.com");
      URL oURL = null;
      try {
      oURL = new URL(strServiceURL);
      }
      catch (Exception ex) {
      //
      }
      oCall.setParams(oParIn);
      System.out.println(oCall.toString());
      //Invoke the service
      System.out.println("\n\nSOAP Client Using Java \n");
      System.out.println("Query submitted to Microsoft SOAP Server
      at ");
      System.out.println("\t" + strServiceURL + "\n");
      System.out.println("Reply from Microsoft SOAP Server:\n");
      System.out.println (oCall.toString());
      Envelope env = oCall.buildEnvelope();
      System.out.println("Envelope:Body");
      System.out.println(env.getBody().toString());
      System.out.println("Envelope:Header");
      System.out.println(env.getHeader());
      System.out.println("------");
      try {
      //oResp = oCall.invoke(oURL, strServiceURL);
      oResp = oCall.invoke(oURL, "");
      }
      catch (SOAPException e) {
      //Show the Fault information, if there is an error
      System.out.println("The SOAPException is: ("
      +e.getFaultCode () + "): " + e.getMessage ());
      return;
      }
      //Retrieve the response value
      if (!oResp.generatedFault()) {
      Parameter oParResult = oResp.getReturnValue();
      Object value = oParResult.getValue();
      System.out.println (value);
      }
      else {
      //Or show the Fault information
      Fault oFault = oResp.getFault ();
      System.out.println ("The system fault is: ");
      System.out.println (" Fault Code = " +
      oFault.getFaultCode());
      System.out.println (" Fault String = " +
      oFault.getFaultString());
      }



      //call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/"
      );

      //call.setTargetObjectURI("http://162.9.204.217/MSSoapSamples/Calc/Ser
      vice/Rpc/IsapiVb/Calc.wsdl");
      //call.setTargetObjectURI("CalcSvcRpcVb.Calc");
      //call.setTargetObjectURI("Calc");
      //call.setTargetObjectURI("http://tempuri.org/type");

      //call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);


      }
      }

      //////////////////////

      and following is the WSDL file

      <?xml version="1.0" encoding="UTF-8" ?>
      - <definitions name="Calc" targetNamespace="http://tempuri.org/wsdl/"
      xmlns:wsdlns="http://tempuri.org/wsdl/"
      xmlns:typens="http://tempuri.org/type"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-extension"
      xmlns="http://schemas.xmlsoap.org/wsdl/">
      - <types>
      <schema targetNamespace="http://tempuri.org/type"
      xmlns="http://www.w3.org/2001/XMLSchema"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" />
      </types>
      - <message name="Calc.Add">
      <part name="A" type="xsd:double" />
      <part name="B" type="xsd:double" />
      </message>
      - <message name="Calc.AddResponse">
      <part name="Result" type="xsd:double" />
      </message>
      - <message name="Calc.Subtract">
      <part name="A" type="xsd:double" />
      <part name="B" type="xsd:double" />
      </message>
      - <message name="Calc.SubtractResponse">
      <part name="Result" type="xsd:double" />
      </message>
      - <message name="Calc.Multiply">
      <part name="A" type="xsd:double" />
      <part name="B" type="xsd:double" />
      </message>
      - <message name="Calc.MultiplyResponse">
      <part name="Result" type="xsd:double" />
      </message>
      - <message name="Calc.Divide">
      <part name="A" type="xsd:double" />
      <part name="B" type="xsd:double" />
      </message>
      - <message name="Calc.DivideResponse">
      <part name="Result" type="xsd:double" />
      </message>
      - <portType name="CalcSoapPort">
      - <operation name="Add" parameterOrder="A B">
      <input message="wsdlns:Calc.Add" />
      <output message="wsdlns:Calc.AddResponse" />
      </operation>
      - <operation name="Subtract" parameterOrder="A B">
      <input message="wsdlns:Calc.Subtract" />
      <output message="wsdlns:Calc.SubtractResponse" />
      </operation>
      - <operation name="Multiply" parameterOrder="A B">
      <input message="wsdlns:Calc.Multiply" />
      <output message="wsdlns:Calc.MultiplyResponse" />
      </operation>
      - <operation name="Divide" parameterOrder="A B">
      <input message="wsdlns:Calc.Divide" />
      <output message="wsdlns:Calc.DivideResponse" />
      </operation>
      </portType>
      - <binding name="CalcSoapBinding" type="wsdlns:CalcSoapPort">
      <stk:binding preferredEncoding="UTF-8" />
      <soap:binding style="rpc"
      transport="http://schemas.xmlsoap.org/soap/http" />
      - <operation name="Add">
      <soap:operation soapAction="http://tempuri.org/action/Calc.Add" />
      - <input>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      - <output>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
      </operation>
      - <operation name="Subtract">
      <soap:operation soapAction="http://tempuri.org/action/Calc.Subtract"
      />
      - <input>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      - <output>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
      </operation>
      - <operation name="Multiply">
      <soap:operation soapAction="http://tempuri.org/action/Calc.Multiply"
      />
      - <input>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      - <output>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
      </operation>
      - <operation name="Divide">
      <soap:operation soapAction="http://tempuri.org/action/Calc.Divide"
      />
      - <input>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </input>
      - <output>
      <soap:body use="encoded" namespace="http://tempuri.org/message/"
      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </output>
      </operation>
      </binding>
      - <service name="Calc">
      - <port name="CalcSoapPort" binding="wsdlns:CalcSoapBinding">
      <soap:address
      location="http://MSSoapSampleServer/MSSoapSamples/Calc/Service/Rpc/Isa
      piVb/Calc.wsdl" />
      </port>
      </service>
      </definitions>

      //////////


      Somehow however it never worked for me. I can make apacheserver -
      client or ms server-client pairs but in this example of mssoap +
      apache client it is giving me error messages.

      can somebody help me with this issue please ? Any java sample codes to
      connect to the MSSOAP will be highly appreciated.

      Regards & Thanks,

      Ash.
    Your message has been successfully submitted and would be delivered to recipients shortly.