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

.Net Server and Perl Client (Code Snippets)

Expand Messages
  • operationsresearch
    Hello, I hope these code snippets are useful. I was new to Perl and SOAP::Lite before I started. So I will also write the problems faced and how they got
    Message 1 of 3 , Nov 9, 2003
    • 0 Attachment
      Hello,

      I hope these code snippets are useful. I was new to Perl and
      SOAP::Lite before I started. So I will also write the problems
      faced and how they got solved.

      .Net Service..
      -----------------------------------------

      <WebMethod()> _
      Public Function methodXXX(ByVal param1 As String, _
      ByVal param2 As String) as Result()
      .......
      .......
      End Function


      SOAP Client
      -------------------------------------------------------------
      my ($param1, $param2) = ('aaa', 'bbb');

      my $soap = SOAP::Lite
      -> uri('http://localhost')
      -> on_action( sub { sprintf '%s/%s', @_ })
      -> proxy('http://localhost:8080/TestWebService/TestService.asmx');

      my $method = SOAP::Data->name('methodXXX')
      ->attr({xmlns => 'http://aaa.bbb.com'});

      my @params = ( SOAP::Data->name(param1 => $param1)->type('string'),
      SOAP::Data->name(param2 => $param2)->type('string'),
      SOAP::Data->name(param3 => $param3)->type('string')
      );

      my $som = $soap->call($method => @params);
      my @result_list = $som->valueof('//Result');

      foreach my $result(@result_list) {
      ...
      ...
      }

      Here are problems that I faced.
      1. The .Net Service was not receiving the values of method
      parameters. It was receiving blank data.

      Solution: a) Used SOAP::Data instead of just $param1

      2. The Perl client received no data.

      Solution:
      a) Added namespace attribute to the $method.
      This namespace should be the same as namespace declared for
      the .Net web service.

      I found this by trial and error after seeing the SOAP messages.

      3. The .Net Service returned a SOAP Fault message

      Solution: Added the on_action method call to SOAP::Lite.
      -> on_action( sub { sprintf '%s/%s', @_ })

      4. The client did not receive the entire list.
      Only last item in the result was being printed.

      Solution: Used the valueof() method instead of result() method
      on the som.

      There were some other problems bcos of improper Perl syntax.
      I am learning Perl and I used $ instead of @ and didnt get
      the correct result.

      But, finally it worked.

      I hope the above list is useful. Any feedback is welcome.

      Ajay
    • Randy J. Ray
      I wrote the following article for perl.com in March of this year. It covers several of the points you learned on your own, as well as a few others. Sorry that
      Message 2 of 3 , Nov 10, 2003
      • 0 Attachment
        I wrote the following article for perl.com in March of this year. It covers
        several of the points you learned on your own, as well as a few others. Sorry
        that I didn't get this to you before you learned the hard way, but I haven't
        been attending to e-mail much this weekend.

        The article is at:

        http://www.perl.com/pub/a/2003/03/26/perlanddotnet.html

        Hope this helps!

        Randy
        --
        """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
        Randy J. Ray Campbell, CA http://www.rjray.org rjray@...

        Silicon Valley Scale Modelers: http://www.svsm.org
      • Maurice McCabe
        Hello All, Would someone be so kind as to post a default .NET client that talks to a default Perl Server. I need to be able to demonstrate this working to a
        Message 3 of 3 , Nov 10, 2003
        • 0 Attachment
          Hello All,
           
          Would someone be so kind as to post a default .NET client that talks to a default Perl Server. I need to be able to demonstrate this working to a customer (by having them run the client) and it would save me having to install Windows/.NET.
           
          I have been using SOAP::Lite and it is excellent. Thanks David, et all, for all your work. I hope to be able to pitch-in myself sometime.
           
          Thanks in advance,
           
          Maurice
           
        Your message has been successfully submitted and would be delivered to recipients shortly.