when using C# null content from any array. WSDL trouble ?

Bug #1096004 reported by ctmidi
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
ladon
Medium
Unassigned

Bug Description

i think that WSDL generation may be broken, or at least incompatible with C# implementation of it as when trying to consume SOAP 1.1 from C#, any array will have null value even if Ladon will actually send some XML data.

i have seen another bug reported here telling that WSDL Array are broken, BTW the provided patch do not help, i think this is still broken and may be inner elements should be contained inside specific node rather than in "item" ?

here is how to reproduce this from the AlbumService example provided :

1/ from any Visual Studio project, as Console Application, first create a Service Web reference like explained here : http://webservices20.blogspot.fr/2008/10/interoperability-gotcha-visual-studio.html for this example called 'albumsWR'

2/ code for the C# apps

---8<---

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using ConsoleApplication6.albumsWR; // PUT HERE THE NAME OF THE "Web References" you provide @ step 1

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            AlbumService albumService = new AlbumService();
            var filteredAlbums = albumService.listAlbums("The");
            if (filteredAlbums.item == null)
            {
              Console.WriteLine("null contained, while it should not!");
            }
        }
    }
}

---8<---

when checking the result with SOAP UI, of course an XML result is provided, if we intercept the data sent with Fiddler to the C# program here is what is provided so one can check that is not a 'null' answer, BTW may be some inconsistencies occurs between the WSDL definition and/or namespace and the result provided, that prevent C# to understand how to unserialize the result ?

---8<---
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns="urn:AlbumService" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <ns:listAlbumsResponse>
     <result>
        <item>
           <band>
          <album-titles>
             <item>Album Of The Year</item>
             <item>KING FOR A DAY - FOOL FOR A LIFETIME</item>
          </album-titles>
          <name>Faith No More</name>
           </band>
           <title>Album Of The Year</title>
           <songs>
          <item>Ashes To Ashes.mp3</item>
          <item>Mouth To Mouth.mp3</item>
          <item>Last Cup Of Sorrow [Sharam Versus Fnm Club Mix] [Bonus Track].mp3</item>
          <item>Paths Of Glory.mp3</item>
          <item>Pristina.mp3</item>
          <item>Light Up And Let Go [Bonus Track].mp3</item>
          <item>Helpless.mp3</item>
          <item>The Big Kahuna [Bonus Track].mp3</item>
          <item>She Loves Me Not.mp3</item>
          <item>Stripsearch.mp3</item>
          <item>Last Cup Of Sorrow.mp3</item>
          <item>Collision.mp3</item>
          <item>Home Sick Home.mp3</item>
          <item>She Loves Me Not [Spinna Crazy Dub Mix] [Bonus Track].mp3</item>
          <item>Last Cup Of Sorrow [Rammstein Mix] [Bonus Track].mp3</item>
          <item>Naked In Front of The Computer.mp3</item>
          <item>Got That Feeling.mp3</item>
          <item>Ashes To Ashes [Hardknox Alternative Mix] [Bonus Track].mp3</item>
           </songs>
        </item>
        <item>
           <band>
          <album-titles>
             <item>Paint The Sky With Stars - The Best Of Enya</item>
          </album-titles>
          <name>Enya</name>
           </band>
           <title>Paint The Sky With Stars - The Best Of Enya</title>
           <songs>
          <item>Watermark.mp3</item>
          <item>Boadicea.mp3</item>
          <item>Storms In Africa.mp3</item>
          <item>Book Of Days.mp3</item>
          <item>Caribben Blue.mp3</item>
          <item>The Celts.mp3</item>
          <item>Anywhere Is.mp3</item>
          <item>Shepherd Moons.mp3</item>
          <item>China Roses.mp3</item>
          <item>Marble Halls.mp3</item>
          <item>On My Way Home.mp3</item>
          <item>Ebudae.mp3</item>
          <item>The Memory Of Trees.mp3</item>
          <item>Paint The Sky With Stars.mp3</item>
          <item>Only If....mp3</item>
          <item>Orinoco Flow.mp3</item>
           </songs>
        </item>
        <item>
           <band>
          <album-titles>
             <item>Zitilites</item>
             <item>No Balance Palace</item>
             <item>Home Dead</item>
             <item>Travelogue</item>
             <item>Cruzential</item>
             <item>The Good Life</item>
          </album-titles>
          <name>Kashmir</name>
           </band>
           <title>The Good Life</title>
           <songs>
          <item>Gorgeous.mp3</item>
          <item>New Year's Eve.mp3</item>
          <item>Lampshade.mp3</item>
          <item>It's OK Now.mp3</item>
          <item>Graceland.mp3</item>
          <item>Miss You.mp3</item>
          <item>Mudbath.mp3</item>
          <item>Mom In Love, Daddy In Space.mp3</item>
          <item>Kiss Me Goodbye.mp3</item>
          <item>Make It Grand.mp3</item>
           </songs>
        </item>
        <item>
           <band>
          <album-titles>
             <item>The Wall CD2</item>
             <item>The Wall Part I</item>
          </album-titles>
          <name>Pink Floyd</name>
           </band>
           <title>The Wall CD2</title>
           <songs>
          <item>Nobody Home.mp3</item>
          <item>Waiting For The Worms.mp3</item>
          <item>Bring The Boys Back Home.mp3</item>
          <item>The Trial.mp3</item>
          <item>Is There Anybody Out There?.mp3</item>
          <item>Comfortably Numb.mp3</item>
          <item>Run Like Hell.mp3</item>
          <item>The Show Must Go On.mp3</item>
          <item>Vera.mp3</item>
          <item>In The Flesh.mp3</item>
          <item>Outside The Wall.mp3</item>
          <item>Hey You.mp3</item>
          <item>Stop.mp3</item>
           </songs>
        </item>
        <item>
           <band>
          <album-titles>
             <item>The Wall CD2</item>
             <item>The Wall Part I</item>
          </album-titles>
          <name>Pink Floyd</name>
           </band>
           <title>The Wall Part I</title>
           <songs>
          <item>The Happiest Days Of Our Lives.mp3</item>
          <item>Another Brick In The Wall (Part 1).mp3</item>
          <item>Goodbye Cruel World.mp3</item>
          <item>One Of The Turns.mp3</item>
          <item>In The Flesh?.mp3</item>
          <item>Empty Spaces.mp3</item>
          <item>The Thin Ice.mp3</item>
          <item>Goodbye Blue Sky.mp3</item>
          <item>Another Brick In The Wall (Part 2).mp3</item>
          <item>Another Brick In The Wall (Part 3).mp3</item>
          <item>Young Lust.mp3</item>
          <item>Mother.mp3</item>
          <item>Don't Leave Now.mp3</item>
           </songs>
        </item>
     </result>
      </ns:listAlbumsResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
---8<---

Changed in ladon:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
jsgaarde (jakob-simon-gaarde) wrote :

I am going to confirm this since there is a problem. I have been in the situation once before but I could not find out what Windows's SOAP implementation expects. I could however conclude that Ladon's WSDL and SOAP envelope generation is consistent and upholding the SOAP standards. The problem is rather that Microsoft's SOAP client implementation is more or less build to work with the Microsoft SOAP server implementation. SOAP is rather flexible which is a problem in the real world, cause very few clients can live up to this flexibility. gSOAP is one of the best client implementations I know of, and it handles Ladons SOAP implementation just fine. So does Suds for Python and most of the PHP SOAP clients. Suds is the client i have used for testing.
BTW: the soap11 interface in Ladon has namespaces, and that doesn't work with Microsoft either, so I doubt that is the problem.

Just to go into solution mode in your case, I suggest you use JSON-WSP instead, there is a C# client here and that works:
https://github.com/mikrov/jsonwsp-cs

Best regards Jakob

Revision history for this message
GaryS (garysh26) wrote :

Hi I am having similar problems. I cannot consume the soap interface (when arrays or complex tyoes are returned) from Visual studio, netbeans, eclipse or any other IDE I have tried. Similar errors in all cases about expecting endof element but finding start. SoapUI is suggesting the wsdl is not valid when I run WSI profile compliance.

One thing I noticed. If I look at a message returned from ladon for a reponse like:

String name;
    double a;
    double b;
    double[] c;

For a web service CREATED with netbeans I get a reponse like this:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:func2Response xmlns:ns2="http://test/">
         <return>
            <a>1.0</a>
            <b>1.0</b>
            <c>1.0</c>
            <c>3.2</c>
            <c>4.5</c>
            <name>hello</name>
         </return>
      </ns2:func2Response>
   </S:Body>
</S:Envelope>

from ladon with a similar reponse objec tI get:

<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:Calculator" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <ns:func2Response>
         <result>
            <a>1.2</a>
            <c>
               <item>1.2</item>
               <item>2.4</item>
               <item>3.6</item>
            </c>
            <b>2.4</b>
            <name>hello 2</name>
         </result>
      </ns:func2Response>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

ie rather than a list of 'c's I get one 'c' and a list of items. I'd be happy to post some examples for various types etc of the wsdl netbeans generates and any messages sent, if that helps - it seems the services it produces are pretty portable and consumed by most clients. So any fomratting it uses may be informative.

Revision history for this message
GaryS (garysh26) wrote :

Hi, I decided to have a go at writing a new interface so the soap format matches that of a tomcat web service generated by netbeans. Thanks to the really neat way ladon is structured it was not too bad! I can now consume a web service in netbeans. It seems to work, for arrays and complex types, with an import from Netbeans and Visual studio. I need to do some more checking but would of course be more than happy to give this interface back to ladon should others find it useful

Revision history for this message
jsgaarde (jakob-simon-gaarde) wrote :

Hi Gary.

Sounds very cool! Can you send me a patch so I can review it and add it to the mainline?

Best Regards
Jakob Simon-Gaarde

Revision history for this message
André (andre-miras) wrote :

I'm also having this issue, I've created a topic in the forum: https://answers.launchpad.net/ladon/+question/230583
GaryS, it would be great if you could submit your patch.

Revision history for this message
André (andre-miras) wrote :

Disclaimer: I don't know very much about SOAP.
I've played with it a bit and I think the issue comes from the .NET client not supporting SOAP operation style="rpc" from the WSDL description. But, this is to be confirmed.
I didn't know how I could step-by-step debug the C# client to see the unserialize part, so I did some "monkey debugging" to understand what exactly the .NET client didn't like.
Here is how I proceeded.
I created a very simple .NET SOAP service that was just returning an array of int. I did the same with Ladon. Then I saved both WSDL description and both responses message and compared them.
I "patched" ladon/interface/soap.py so it returned the .NET WSDL and response hardcoded. Then I tried to make them converge by changing the .NET WSDL and response with little iterations and I checked with the C# client if it broke or not.
I went to a point where both response were almost similar, but with slightly different WSDL (one using document operation, the other using RPC).
The next step is to create a soapdotnet.py service by drawing inspiration from modified XML response (easy) and WSDL description (harder).
I'll attach the files I used, the first is the simple Ladon service Python description.
I'm not sure I'll be able to work on draft patch as we're switching to a gsoap sever because of this issue.

Revision history for this message
André (andre-miras) wrote :

Attached is the .NET WSDL I modified so it looks like the Ladon WSDL.
It works with the C# SOAP client and Python Suds client.
As I explained in my comment below, the main difference is it's using Document/Literal format rather than RPC.

Revision history for this message
André (andre-miras) wrote :

Attached is the generated XML response that works with a C# SOAP client even though it's very similar to the one generated by Ladon.
The main differences are within the xmlns attributes.

Revision history for this message
André (andre-miras) wrote :

Attached is the Ladon WSDL I used for reference to change the .NET compliant WSDL.

Revision history for this message
André (andre-miras) wrote :

The Ladon XML response I used for reference to change the .NET compliant XML response.

Revision history for this message
André (andre-miras) wrote :

I've worked on a custom interface that seems to work for my test cases and for the AlbumService.
Attached is a draft of it (to copy in ladon/interfaces/soapdocumentliteral.py).
The code is not cleaned and I'm still not a SOAP guru, but I think it's a good start. I may release another patch later.
Jsgaarde, what's the best way to contribute? Do you have a preferred method (patch, GitHub, ...)? Is there some unit tests you're using, I can draw inspiration from to write my own tests?

Revision history for this message
André (andre-miras) wrote :

I've attached the patch that fixes the issue for a C# client.

Revision history for this message
jsgaarde (jakob-simon-gaarde) wrote :

I will test this later today. Thanks for yourcontribution André!

Best regards Jakob Simon-Gaarde

Revision history for this message
jsgaarde (jakob-simon-gaarde) wrote :

Hi André

I was wondering if we could maybe find a better interface name (meaning shorter) ;-)

/ Jakob Simon-Gaarde

Revision history for this message
André (andre-miras) wrote :

Hi Jakob,
Yes the interface name is long but meaningful.
I'm not very inspired for a shorter one, but you can try with "SoapDocLiteral", "SoapDotNet" or "SoapNet". Feel free to give any other name that better fits you.

Revision history for this message
jsgaarde (jakob-simon-gaarde) wrote :

Hi André

Your ingerface contribution just got the honor of being named "soap".

/ Jakob

Changed in ladon:
status: Confirmed → Fix Committed
Revision history for this message
André (andre-miras) wrote :

Great news, I hope it won't make any regression.

Revision history for this message
MichaelRazoum (michael-razoumovitch) wrote :

Hi André,

I had problems with the soap Interface with complexType or lists arguments (https://bugs.launchpad.net/ladon/+bug/1306028). Could you perhaps look over it? I have found a simple solution, but I'm unsure about it.

Thanks
Michael

Revision history for this message
André (andre-miras) wrote :

Hi, I'm not a Ladon maintainer, but I thin jsgaarde is busy. I'll take a look at it.

Revision history for this message
jsgaarde (jakob-simon-gaarde) wrote :

Hi I am gonna look at some of the pending bugs on wednesday, this one included.

Revision history for this message
MichaelRazoum (michael-razoumovitch) wrote :

Thanks,

Michael

To post a comment you must log in.