ferterra / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

Client not working with WCF service that exposes nullable DataMember's on input contracts #160

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create WCF service that accepts an input object that is a POCO containing 
nullable value type properties
2. Call the service from PySimpleSoapClient setting any of the properties to 
None
3. An error occurs

What is the expected output? What do you see instead?
Expected that the python NoneType gets sent to the backend as a C# null.  
Instead, an error occurs:

  ValueError: Invalid Args Structure. Errors: [u"Type mismatch for argument value. parameter(<type 'type'>): <type 'int'>, value(<type 'NoneType'>): None"]

Please use labels and text to provide additional information.
Given a a WCF service (full wsdl attached):

    [ServiceContract]
    public class TestService
    {
        [OperationContract]
        public string InputTest(TestObject fooInput)
        {
            return string.Format("Number: {0}, OptionalNumber: {1}", fooInput.Number, fooInput.OptionalNumber);
        }
    }

    [DataContract]
    public class TestObject
    {
        [DataMember]
        public int Number { get; set; }

        [DataMember]
        public int? OptionalNumber { get; set; } //this is a nullable int
    }

And a PySimpleSoap client:

from pysimplesoap.client import SoapClient
client = SoapClient(wsdl="http://127.0.0.1:7072/TestService.svc?wsdl")

result = client.InputTest(fooInput={"Number":30, "OptionalNumber": 20})
print result
#prints {'InputTestResult': u'Number: 30, OptionalNumber: 20'}

result = client.InputTest(fooInput={"Number":30, "OptionalNumber": None})
#error occurs here
print result

I have fixed the issue in my fork and will submit a pull request shortly.

Original issue reported on code.google.com by d.li...@gmail.com on 29 Sep 2014 at 7:41

Attachments:

GoogleCodeExporter commented 9 years ago
Pull request #22 submitted

Original comment by d.li...@gmail.com on 30 Sep 2014 at 2:09

GoogleCodeExporter commented 9 years ago
Has anybody had a chance to review my pull request?  I'm eager to get this 
merged into the the main project.  If there are any concerns about my change or 
tests I can provide, please let me know.

THanks,
Dan

Original comment by d.li...@gmail.com on 27 Oct 2014 at 1:17

GoogleCodeExporter commented 9 years ago
Thanks, merged! 

Sorry for the delay, I'm in the middle of my master's thesis so I don't have 
much time to deeply review this PR right now.

I don't see any problem in advance, and I'll make a full review and test update 
possibly in late November to release a new stable version.

If you can send an additional automatic unit test, that would be useful too.

Thanks again for your contributions, please feel free to close this issue if it 
is solved an no regression in the other tests was introduced.

Original comment by reingart@gmail.com on 27 Oct 2014 at 5:36

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 3b14d52f5e8e.

Original comment by reingart@gmail.com on 27 Oct 2014 at 6:36