As others have pointed out, SOAP is designed to interoperate between disparate systems, however it can be relatively difficult to get something working with a server created in a dynamically typed language like Perl and a client in a more strongly typed language such as C# - the temptation to create complex datastructures in Perl for instance can confound the ability to define a class into which it can be deserialized in C#, so the touchstone is to be conservative with the data you are exchanging and to think more in terms of passing documents than objects defined in the respective languages.

Also the .NET web services framework really does prefer that your services are defined in a WSDL document, so if you are able to create one for your Perl server then you are going to find it easier to create your client using for instance the wsdl tool supplied.

All that said a C# client for a simple service that just returns a single string is going to be as simple as:

using System; using System.Web.Services; using System.Web.Services.Protocols; + [System.Web.Services.WebServiceBinding(Namespace="http://tempuri.org/H +ello"), public class Hello : SoapHttpClientProtocol { + public Hello () { this.Url = "http://yoururl/cgi-bin/hello.pl"; } + + [SoapDocumentMethod("http://tempuri.org/Hello/HelloWorld")] public virtual string HelloWorld() { System.Object[] results = this.Invoke("HelloWorld", new object +[0]); return ((string)(results[0])); } + + public static void Main() { Hello foo = new Hello(); Console.WriteLine(foo.HelloWorld()); } }
Aplogies for the untested non-Perl code. YOur Perl server could be something like:
#! /usr/bin/perl use strict; use SOAP::Transport::HTTP; + use lib '/var/www/cgi-bin/soap_modules'; + use Hello; + SOAP::Transport::HTTP::CGI -> dispatch_to( 'Hello') -> handle;
With a Hello.pm that is simply:
package Hello; + sub HelloWorld { return ("Hello, World"); } + 1;

/J\


In reply to Re: C# client for Soap::Lite by gellyfish
in thread C# client for Soap::Lite by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.