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

SOAP::Lite client, .NET web service interop problem

Expand Messages
  • rajmalli
    Hi I am trying to access a .NET web service via a SOAP::Lite client and have problems. Here is my .NET web service method: [WebMethod] [SoapRpcMethod] public
    Message 1 of 2 , Mar 24, 2004
    • 0 Attachment
      Hi

      I am trying to access a .NET web service via a SOAP::Lite client and
      have problems.

      Here is my .NET web service method:

      [WebMethod]
      [SoapRpcMethod]
      public ArrayList GetAllMachines(string group) {
      DataSet ds = GetMachinesAndGroups();

      ArrayList list = new ArrayList();
      foreach (DataRow currentRow in ds.Tables[0].Rows) {
      string hostName = (string) currentRow["HostName"];
      string groupName = (string) currentRow["GroupName"];
      if ((group == groupName) || (group == "all")) list.Add
      (hostName);
      }

      return list;
      }

      I have defined this method to be a SoapRpcMethod so that SOAP::Lite
      knows how to interpret the array (all of whose elements have the
      same element name) returned. Otherwise, I need to extract the
      contents of the array with a valueof call.

      And this is how I make the SOAP::Lite call:

      use strict;
      use SOAP::Lite;

      my $ns = 'http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebService';
      my $params = {
      uri => $ns,
      proxy
      => 'http://rmalli/AGMWebService/AGMWebService.asmx',
      on_action => sub { sprintf '%s/%s', @_ },
      on_debug => sub { print "@_ \n" }
      };

      # Create a proxy for the Web service
      my $proxy = SOAP::Lite->new(%$params);

      my ($method, $args);

      $method = "GetAllMachines";
      $args = { group => "AST Test Systems" };
      ExecuteMethod($proxy, $ns, $method, $args);

      sub ExecuteMethod {
      my ($proxy, $ns, $methodName, $args) = @_;

      my $method = SOAP::Data->name($methodName)->attr({xmlns => $ns});
      my @params;
      foreach (keys %$args) {
      push(@params, SOAP::Data->name($_ => $args->{$_}));
      }

      return $resp;
      }

      The problem is that the value of "group" on the web service method
      is always null. So, I know that the right method is being called,
      but since the input argument is null, I get an empty array as output.

      The SOAP packet sent out is
      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-
      ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-
      ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="h
      ttp://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-
      ENV:Body><GetAllMachines xmlns="http://www.qualcomm.c
      om/QCT/AST/TestSystems/AGMWebService"><group
      xsi:type="xsd:string">AST Test
      Systems</group></GetAllMachines></SOAP-ENV:Body></SOAP-ENV:Envelope>

      What is wrong with this?

      I can invoke this method successfully using the following SOAP packet
      which is the packet generated when I debug my web service using IE.

      POST /AGMWebService/AGMWebService.asmx HTTP/1.1
      Host: localhost
      Content-Type: text/xml; charset=utf-8
      Content-Length: length
      SOAPAction: "http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebServic
      e/GetAllMachines"

      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:tns="http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebService"

      xmlns:types="http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebServic
      e/encodedTypes"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <tns:GetAllMachines>
      <group xsi:type="xsd:string">string</group>
      </tns:GetAllMachines>
      </soap:Body>
      </soap:Envelope>

      What is the difference between the two?

      Appreciate any help

      Raj
    • rajmalli
      Forgot to add that if I remove the SoapRpcMethod attribute from the web service method, then the group value is correctly passed by the perl code and the
      Message 2 of 2 , Mar 26, 2004
      • 0 Attachment
        Forgot to add that if I remove the SoapRpcMethod attribute from the
        web service method, then the group value is correctly passed by the
        perl code and the correct value is returned by the web service
        method. Since the return value is an array of elements of the same
        name, I need to use valueof to extract the elements

        Thanks
        Raj

        --- In soaplite@yahoogroups.com, "rajmalli" <rajmalli@y...> wrote:
        > Hi
        >
        > I am trying to access a .NET web service via a SOAP::Lite client
        and
        > have problems.
        >
        > Here is my .NET web service method:
        >
        > [WebMethod]
        > [SoapRpcMethod]
        > public ArrayList GetAllMachines(string group) {
        > DataSet ds = GetMachinesAndGroups();
        >
        > ArrayList list = new ArrayList();
        > foreach (DataRow currentRow in ds.Tables[0].Rows) {
        > string hostName = (string) currentRow["HostName"];
        > string groupName = (string) currentRow["GroupName"];
        > if ((group == groupName) || (group == "all")) list.Add
        > (hostName);
        > }
        >
        > return list;
        > }
        >
        > I have defined this method to be a SoapRpcMethod so that
        SOAP::Lite
        > knows how to interpret the array (all of whose elements have the
        > same element name) returned. Otherwise, I need to extract the
        > contents of the array with a valueof call.
        >
        > And this is how I make the SOAP::Lite call:
        >
        > use strict;
        > use SOAP::Lite;
        >
        > my $ns
        = 'http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebService';
        > my $params = {
        > uri => $ns,
        > proxy
        > => 'http://rmalli/AGMWebService/AGMWebService.asmx',
        > on_action => sub { sprintf '%s/%s', @_ },
        > on_debug => sub { print "@_ \n" }
        > };
        >
        > # Create a proxy for the Web service
        > my $proxy = SOAP::Lite->new(%$params);
        >
        > my ($method, $args);
        >
        > $method = "GetAllMachines";
        > $args = { group => "AST Test Systems" };
        > ExecuteMethod($proxy, $ns, $method, $args);
        >
        > sub ExecuteMethod {
        > my ($proxy, $ns, $methodName, $args) = @_;
        >
        > my $method = SOAP::Data->name($methodName)->attr({xmlns =>
        $ns});
        > my @params;
        > foreach (keys %$args) {
        > push(@params, SOAP::Data->name($_ => $args->{$_}));
        > }
        >
        > return $resp;
        > }
        >
        > The problem is that the value of "group" on the web service method
        > is always null. So, I know that the right method is being called,
        > but since the input argument is null, I get an empty array as
        output.
        >
        > The SOAP packet sent out is
        > <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
        xmlns:SOAP-
        > ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-
        > ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:SOAP-ENV="h
        > ttp://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        > xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-
        > ENV:Body><GetAllMachines xmlns="http://www.qualcomm.c
        > om/QCT/AST/TestSystems/AGMWebService"><group
        > xsi:type="xsd:string">AST Test
        > Systems</group></GetAllMachines></SOAP-ENV:Body></SOAP-
        ENV:Envelope>
        >
        > What is wrong with this?
        >
        > I can invoke this method successfully using the following SOAP
        packet
        > which is the packet generated when I debug my web service using IE.
        >
        > POST /AGMWebService/AGMWebService.asmx HTTP/1.1
        > Host: localhost
        > Content-Type: text/xml; charset=utf-8
        > Content-Length: length
        >
        SOAPAction: "http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebServic
        > e/GetAllMachines"
        >
        > <?xml version="1.0" encoding="utf-8"?>
        > <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-
        instance"
        > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        >
        xmlns:tns="http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebService"
        >
        >
        xmlns:types="http://www.qualcomm.com/QCT/AST/TestSystems/AGMWebServic
        > e/encodedTypes"
        > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        > <soap:Body
        > soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        > <tns:GetAllMachines>
        > <group xsi:type="xsd:string">string</group>
        > </tns:GetAllMachines>
        > </soap:Body>
        > </soap:Envelope>
        >
        > What is the difference between the two?
        >
        > Appreciate any help
        >
        > Raj
      Your message has been successfully submitted and would be delivered to recipients shortly.