Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Not Deserializing. Why is my parameter NULL?

I'm trying to setup a web service that will accept predefined incoming SOAP/XML messages. I have no control over the client code or the SOAP message sent. I'm trying a simple example and am having a problem with it. Let's say that this is the SOAP message:

    <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <CustomerRequest xmlns="http://tempuri.org">
      <Customer>
        <FirstName>John</FirstName>
        <LastName>Doe</LastName>
      </Customer>
    </CustomerRequest>
  </env:Body>
</env:Envelope>

And my object with data contract:

[DataContract(Name = "Customer", Namespace = "http://tempuri.org")]
public class Customer
{
    [DataMember]
    public string FirstName { get; set; }

    [DataMember]
    public string LastName { get; set; }
}

Service Interface:

[ServiceContract(Namespace = "http://tempuri.org")]
public interface IService1
{
    [OperationContract(Action="*")]
    [WebInvoke(Method = "POST")]
    bool Customer(Customer customer);
}

When I send over the SOAP request I can view everything in fiddler and it looks to be fine. But when it hits my code, the Customer object is null. I feel like I'm missing something very simple.

Here is also the raw request:

POST http://127.0.0.1.:3619/Service1.svc HTTP/1.1
SOAPAction: http://tempuri.org/IService1/Customer
Content-Type: text/xml;charset=utf-8
Host: 127.0.0.1.:3619
Content-Length: 339
Expect: 100-continue
Connection: Keep-Alive

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <CustomerRequest xmlns="http://tempuri.org">
      <Customer>
        <FirstName>John</FirstName>
        <LastName>Doe</LastName>
      </Customer>
    </CustomerRequest>
  </env:Body>
</env:Envelope>
like image 319
Papa Burgundy Avatar asked Nov 03 '22 14:11

Papa Burgundy


1 Answers

I can't see any mention of CustomerRequest in your interface or service implementation. I think the SOAP request should be sending a Customer rather than CustomerRequest. You can verify this by using SOAPUI and generating a sample request based on your WSDL. Will tell you what the request should actually look like.

like image 72
Nick Ryan Avatar answered Nov 10 '22 15:11

Nick Ryan