Problems getting Python client (SOAPpy) to consume .NET web services

Discussion in 'ASP .Net Web Services' started by Michael Hatmaker, Sep 13, 2004.

  1. I have begun experimenting with web services, and I created some
    simple web services in C# and was able to install them with IIS and
    create an equally simple C# client to consume them.

    My next experiment was to use Python to consume these same web
    services, and even though I am able to get Python to consume web
    services from a variety of sources (Apache SOAP, Glue, AXIS), I cannot
    get web services created with MS.NET to work. Actually, methods with
    no arguments work fine, but any methods that take arguments do not
    work. There is no error, it is simply that an incorrect result is
    returned (i.e. my simple Add(int a, int b) web service always returns
    zero).

    I tried playing around with the
    [SoapDocumentService(Use=SoapBindingUse.Literal,
    ParameterStyle=SoapParameterStyle.Wrapped)] arguments in .NET, but I
    have had no success as of yet. I don't think it's just me since I
    cannot consume any of the web services on webmethods.net that are
    created using MS.NET.

    My Python code looks something like this:

    from SOAPpy import WSDL
    server = WSDL.Proxy('http://localhost/MyWebServices/FirstService.asmx?WSDL')
    server.SayHello() # works correctly - just prints a hello message
    server.Add(3, 4) # does not work - returns zero

    Any tip that would point me in the right direction would be greatly
    appreciated!
     
    Michael Hatmaker, Sep 13, 2004
    #1
    1. Advertising

  2. Michael Hatmaker wrote:

    > I have begun experimenting with web services, and I created some
    > simple web services in C# and was able to install them with IIS and
    > create an equally simple C# client to consume them.
    >
    > My next experiment was to use Python to consume these same web
    > services, and even though I am able to get Python to consume web
    > services from a variety of sources (Apache SOAP, Glue, AXIS), I cannot
    > get web services created with MS.NET to work. Actually, methods with
    > no arguments work fine, but any methods that take arguments do not
    > work. There is no error, it is simply that an incorrect result is
    > returned (i.e. my simple Add(int a, int b) web service always returns
    > zero).
    >
    > I tried playing around with the
    > [SoapDocumentService(Use=SoapBindingUse.Literal,
    > ParameterStyle=SoapParameterStyle.Wrapped)] arguments in .NET, but I
    > have had no success as of yet. I don't think it's just me since I
    > cannot consume any of the web services on webmethods.net that are
    > created using MS.NET.
    >
    > My Python code looks something like this:
    >
    > from SOAPpy import WSDL
    > server = WSDL.Proxy('http://localhost/MyWebServices/FirstService.asmx?WSDL')
    > server.SayHello() # works correctly - just prints a hello message
    > server.Add(3, 4) # does not work - returns zero
    >
    > Any tip that would point me in the right direction would be greatly
    > appreciated!

    I tried this some time before, too. Actually cannot remember, if I finally
    succeeded. I think using keyword arguments in Python got me one step further, e.g.:
    server.Add(a=3, b=4)
     
    Benjamin Niemann, Sep 14, 2004
    #2
    1. Advertising

  3. Nice catch! Actually, I had tried that once, but there is one more
    trick to make this work (that I had since added). You must add the
    following line in your C# web service (I put it before the
    [WebService(Namespace=...] line):

    [SoapDocumentService (Use=SoapBindingUse.Encoded)]

    (and I also think you need to import the following:)

    using System.Web.Services.Protocols;
    using System.Web.Services.Description;
    using System.Xml.Serialization;

    So for anyone else that is having this problem, the solution is the
    combination of the two: (1) You must ad the [SoapDocumentService
    (Use=SoapBindingUse.Encoded)] line to your web service (along with all
    the appropriate "using" statements shown above) and (2) you must
    specify the arguments by name in the method call like "server.Add(a=3,
    b=5)".

    Phew. Thanks again for making me go back and take a look at that named
    arguments thing. I still don't know if there is hope for using a .NET
    web service that I didn't write (such as those on www.xmethods.net),
    but I'll be sure to let everyone know if I find a solution.

    Benjamin Niemann <> wrote in message news:<ci6ana$445$>...
    > Michael Hatmaker wrote:
    >
    > > I have begun experimenting with web services, and I created some
    > > simple web services in C# and was able to install them with IIS and
    > > create an equally simple C# client to consume them.
    > >
    > > My next experiment was to use Python to consume these same web
    > > services, and even though I am able to get Python to consume web
    > > services from a variety of sources (Apache SOAP, Glue, AXIS), I cannot
    > > get web services created with MS.NET to work. Actually, methods with
    > > no arguments work fine, but any methods that take arguments do not
    > > work. There is no error, it is simply that an incorrect result is
    > > returned (i.e. my simple Add(int a, int b) web service always returns
    > > zero).
    > >
    > > I tried playing around with the
    > > [SoapDocumentService(Use=SoapBindingUse.Literal,
    > > ParameterStyle=SoapParameterStyle.Wrapped)] arguments in .NET, but I
    > > have had no success as of yet. I don't think it's just me since I
    > > cannot consume any of the web services on webmethods.net that are
    > > created using MS.NET.
    > >
    > > My Python code looks something like this:
    > >
    > > from SOAPpy import WSDL
    > > server = WSDL.Proxy('http://localhost/MyWebServices/FirstService.asmx?WSDL')
    > > server.SayHello() # works correctly - just prints a hello message
    > > server.Add(3, 4) # does not work - returns zero
    > >
    > > Any tip that would point me in the right direction would be greatly
    > > appreciated!

    > I tried this some time before, too. Actually cannot remember, if I finally
    > succeeded. I think using keyword arguments in Python got me one step further, e.g.:
    > server.Add(a=3, b=4)
     
    Michael Hatmaker, Sep 15, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Saumendra
    Replies:
    0
    Views:
    1,266
    Saumendra
    Jun 24, 2003
  2. Michael Hatmaker
    Replies:
    2
    Views:
    670
    Michael Hatmaker
    Sep 15, 2004
  3. mohit
    Replies:
    2
    Views:
    861
    Simon Brunning
    Jan 12, 2007
  4. John
    Replies:
    4
    Views:
    502
  5. dgleeson422111

    consume local web service -ok consume remote service - Not OK

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    1,659
    dgleeson422111
    Jan 31, 2010
Loading...

Share This Page