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

4880Calling .Net Web Service using a PERL client

Expand Messages
  • vinit samel
    Sep 8, 2005
    • 0 Attachment
      Hello

      I am trying to send an object as a parameter to a .NET
      web service from a perl client with soap::lite.It
      works fine with integers, strings as arguments but has
      trouble with Objects.
      Please find my code below and let me know of how this
      can be done.

      Thanks for all your help,
      Vinit


      ---------------------------------
      Perl Client:
      ---------------------------------
      use MySoapObject;

      my $test = MySoapObject->new(
      proxy =>
      "http://localhost/TestWebService/Service1.asmx",
      uri =>
      "http://www.xxx.com/xxx/xxxSystems",
      #on_debug => sub {
      print "@_\n" }
      );

      my $name = "GetVersionInfo";
      my $params = {};
      my $xpath = "";
      my @ret = $test->ExecSoapMethod($name, $params,
      $xpath);
      print Dumper($ret[1]), "\n";

      $name = "SayHello3";
      $params = { person=> { FirstName => 'Vinit', LastName
      => 'Samel' } };
      $xpath = "";
      @ret = $test->ExecSoapMethod($name, $params, $xpath);
      print Dumper($ret[1]), "\n";

      -----------------------------------------
      .NET WebService
      -----------------------------------------

      namespace TestWebService
      {

      [WebService(Namespace="http://www.xxx.com/xxx/xxxSystems")]
      public class Service1 :
      System.Web.Services.WebService
      {
      public Service1()
      {
      InitializeComponent();
      }

      [WebMethod]
      public string GetVersionInfo()
      {
      return "1.0.0";
      }

      [WebMethod]

      public string SayHello3(Person person)
      {
      if (person != null)
      return "Hello " + person.FirstName + " " +
      person.LastName;
      else
      return "Hello Nobody";

      }

      }

      public class Person
      {
      public Person()
      {
      }

      public Person(string fn, string ln)
      {
      FirstName = fn;
      LastName = ln;
      }

      public string FirstName
      {
      get { return _firstName; }
      set { _firstName = value; }
      }

      public string LastName
      {
      get { return _lastName; }
      set { _lastName = value; }
      }

      private string _firstName;
      private string _lastName;
      }
      }

      -------------------------------------------
      Fault code:
      $VAR1 = 'Fault Code: [soap:Client], Fault String:
      [Server was unable to read request. --> There is an

      error in XML document (1, 467). --> The specifie
      d type was not recognized: name=\'SOAPStruct\',
      namespace=\'http://xml.apache.org/xml-soap\', at

      <person
      xmlns=\'http://www.xxx.com/xxx/xxxSystems\'>.]';
      -------------------------------------------

      Request and response for Method SayHello3

      POST /TestWebService/Service1.asmx HTTP/1.1
      Host: localhost
      Content-Type: text/xml; charset=utf-8
      Content-Length: length
      SOAPAction:
      "http://www.xxx.com/xxx/xxxSystems/SayHello3"

      <?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:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <SayHello3
      xmlns="http://www.xxx.com/xxx/xxxSystems">
      <person>
      <FirstName>string</FirstName>
      <LastName>string</LastName>
      </person>
      </SayHello3>
      </soap:Body>
      </soap:Envelope>
      HTTP/1.1 200 OK
      Content-Type: text/xml; charset=utf-8
      Content-Length: length

      <?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:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <SayHello3Response
      xmlns="http://www.xxx.com/xxx/xxxSystems">
      <SayHello3Result>string</SayHello3Result>
      </SayHello3Response>
      </soap:Body>
      </soap:Envelope>
      -----------------------------------------------





      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam
      protection around
      http://mail.yahoo.com

      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com
    • Show all 3 messages in this topic