WCF Service doesn't recognize an XML element namespace when receiving a HTTP POST SOAP request

Hey everyone!

I have created an interface and implemented it as a WCF web service from a WSDL file I received from a 3rd party. A method on the server is supposed to be invoked by that 3rd party via a HTTP POST message, so I set the service binding property to basicHttpBinding.

Now, if I create a test client by adding a service reference to my service implementation, it works fine. However, when the SOAP message from the 3rd party is received, the method does get invoked, however the parameter that is supposed to get passed to it, is null.

I enabled WCF tracing in the web.config file and by analyzing the trace file, I found out it doesn't like the namespace of the parameter.

The error is:

Description      An unrecognized element was encountered in the XML during deserialization which was ignored.
Element      http://tempuri.org/XMLSchema.xsd:payload

Below is the relevant code and the XML/SOAP request that doesn't work as it should.

Any idea would be greatly appreciated.

Thanks,
Darko
[System.Web.Services.WebServiceBindingAttribute(Name = "CPServiceSoap", Namespace = "http://tempuri.org/")]
    [ServiceContract]
    public interface ICPServiceSoap
    {
        [System.Web.Services.WebMethodAttribute()]
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("SendCustomerRequest", RequestNamespace = "http://tempuri.org/", ResponseNamespace = "http://tempuri.org/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        [OperationContract(IsOneWay = true, Action="http://tempuri.org/SendCustomerRequest")]
        void SendCustomerRequest([System.Xml.Serialization.XmlElementAttribute(Namespace = "http://tempuri.org/XMLSchema.xsd")] payload payload);
    }
 
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tempuri.org/XMLSchema.xsd")]
    [DataContract]
    public partial class payload
    {
        private MessageType messageField;
 
        [DataMember]
        public MessageType Message
        {
            get
            {
                return this.messageField;
            }
            set
            {
                this.messageField = value;
            }
        }
    }
 
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tempuri.org/XMLSchema.xsd")]
    [DataContract]
    public partial class MessageType
    {
 
        private string typeOfMessageField;
 
        private string dataField;
 
        [DataMember]
        public string TypeOfMessage
        {
            get
            {
                return this.typeOfMessageField;
            }
            set
            {
                this.typeOfMessageField = value;
            }
        }
 
        [DataMember]
        public string Data
        {
            get
            {
                return this.dataField;
            }
            set
            {
                this.dataField = value;
            }
        }
    }
 
 
 
/// Request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Body>
    <ns0:SendCustomerRequest xmlns:ns0="http://tempuri.org/">
      <ns1:payload xmlns:ns1="http://tempuri.org/XMLSchema.xsd">
        <ns1:Message>
          <ns1:TypeOfMessage>Text</ns1:TypeOfMessage>
          <ns1:Data>Jgam</ns1:Data>
        </ns1:Message>
      </ns1:payload>
    </ns0:SendCustomerRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Open in new window

LVL 22
DarkoLordAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

topdog770Commented:
You may have already seen this link..
http://social.msdn.microsoft.com/Forums/en-US/biztalkr2adapters/thread/fc00a34f-2112-42ee-ac62-3bcc927c7887
But it outlines the basic detective track.
0
DarkoLordAuthor Commented:
Hi,

thanks for the link - I've seen it, though.

There were two problems, both solved now, fortunately.

The first one was the namespace, which was different for the Payload parameter - I had to add a "dummy" element with the correct namespace in order for it to work.

The second problem was that the order of the parameters was different from what WCF expected - I added the Order attribute to each of the parameters and it started working.

Cheers,
Darko
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WCF

From novice to tech pro — start learning today.