Blair,
Haven't tried it with .NET yet, but imagine it is the same issue as calling
an MSSOAP service from an Apache Client. You need a  return type mapping to
deserialize the result.

Below is the client code for a simple MSSOAP service call. You can probably
try the same thing with .NET and get it working.

Hope this helps.
Brian

  // URIs for the service itself, and for the specific action (needs to
match the method)
  private String serviceURL =
"http://bnoyesnotebook:80/SOAP/SimpleReceiver2.wsdl";;
  private String SOAPActionURI1 =
"http://tempuri.org/action/SimpleReceiver2.Tune";;
  private String SOAPActionURI2 =
"http://tempuri.org/action/SimpleReceiver2.Name";;
  private Call call = new Call();
  protected void makeTheCall()
  {
    URL url;
    try {
      url = new URL(serviceURL);
    }
    catch (MalformedURLException mue)
    {
      System.out.println("Malformed URL!");
      return;
    }
    // Set URIs
    call.setTargetObjectURI("http://tempuri.org/message/";);
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    // Set up return result type mapping
    SOAPMappingRegistry smr = new SOAPMappingRegistry();
    StringDeserializer sd = new StringDeserializer ();
    smr.mapTypes (Constants.NS_URI_SOAP_ENC,new QName ("", "Result"), null,
null, sd);
    call.setSOAPMappingRegistry(smr);

    // Set up parameters
    Vector params = new Vector();
    Double freqval = new Double(123.45);
    Parameter aStr = new Parameter("freq", double.class, freqval, null);
    params.addElement(aStr);
    call.setParams(params);

    // Try invoking the service
    try {
      // First call Tune method
      call.setMethodName("Tune");
      Response resp = call.invoke(url, SOAPActionURI1);

      // Check the response.
      if (resp.generatedFault())
      {
        Fault fault = resp.getFault();
        throw new SOAPException(fault.getFaultCode(),
fault.getFaultString());
      }
      else
      {
        Parameter retValue = resp.getReturnValue();
        String retval = (String)retValue.getValue();
        System.out.println(retval);
        outputArea.append(retval + "\n");
      }

      // Now call Name method
      call.setMethodName("Name");
      Vector emptyParams = new Vector();
      call.setParams(emptyParams);
      resp = call.invoke(url, SOAPActionURI2);

      // Check the response.
      if (resp.generatedFault())
      {
        Fault fault = resp.getFault();
        throw new SOAPException(fault.getFaultCode(),
fault.getFaultString());
      }
      else
      {
        Parameter retValue = resp.getReturnValue();
        String retval = (String)retValue.getValue();
        System.out.println(retval);
        outputArea.append(retval + "\n");

      }
    }
    catch (SOAPException se)
    {
      System.out.println(se.getMessage());
      return;
    }
    return;

  }

-----Original Message-----
From: Blair Tingey [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 11, 2001 8:32 AM
To: [EMAIL PROTECTED]
Subject: Apache SOAP Client to MS .NET



I have been trying to use Apache SOAP classes as a client to a MS .NET
service without much luck.

There are some .NET services listed on the XMethods site (
http://www.xmethods.com), they are: Prasad's Stock Quote Service, Breaking
News Service, and ZipCodes. I have included the code that I have tried to
use for these services.

Because I am new to SOAP, I know I'm missing something trivial but I
just can't see it. Can anyone see where I am going wrong?

Thanks,
Blair Tingey
[EMAIL PROTECTED]

=============
Client
============
//
// Sample client for the GetStock Quote -> MS .NET Service
//

import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;

public class GetStockQuote{

  public static String GetStock (URL url, String symbol) throws Exception{

    Call call = new Call ();

    // This service uses standard SOAP encoding
    String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
    call.setEncodingStyleURI(encodingStyleURI);
    call.setTargetObjectURI ("GetNasdaqQuotes");
    call.setMethodName ("GetNasdaqQuotes");

    // Create input parameter vector
     Vector params = new Vector ();
     params.addElement (new Parameter("SymbolsAsString", String.class,
                                         symbol, null));
     call.setParams (params);

    // Evoke the service...
    Response resp = call.invoke (url,"
http://localhost/webservices/GetNasdaqQuotes";);

    // ... and evaluate the result
    if (resp.generatedFault ()) {
     Fault fault = resp.getFault();
        System.err.println("Generated fault: ");
        System.out.println("  Fault Code   = " + fault.getFaultCode());
        System.out.println("  Fault String = " + fault.getFaultString());
        throw new Exception();
     }else {
      // Successful call. Extract result and return value
      Parameter result = resp.getReturnValue ();
      String location = (String) result.getValue();
     return(location);
    }
  }

public static void main(String[] args)
  {
    try {
     URL url=new URL("
http://www22.brinkster.com/prasads/LiveQuoteService.asmx";);
     String stockNews = GetStock(url,"AAPL");
     System.out.println(stockNews);
    }catch (Exception e) {e.printStackTrace();}
  }
}

Reply via email to