0

I wrote a WCF client and the client adds a header to the request by calling:

var newHeader = MessageHeader.CreateHeader("CallingPartnerInfo", string.Empty, callingPartnerInfo); 

And class CallingPartnerInfo is defined as below.

[DataContract]
internal class CallingPartnerInfo
{
    [DataMember]
    public bool IsWindowsIdentity { get; set; }

    [DataMember]
    public Guid CallingPartnerGuid { get; set; }
}

The problem is the serialized header has unwanted namespace (xmlns="http://schemas.datacontract.org/2004/07/CTPCommerceDeployTests") attached to each field. What did I do wrong? How can I get these xmlns not created?

<CallingPartnerInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<CallingPartnerGuid xmlns="http://schemas.datacontract.org/2004/07/CTPCommerceDeployTests">9ee1dbbc-5ff7-4a26-aadb-2226aa166a0d</CallingPartnerGuid>
<CallingPartnerIpAddress xmlns="http://schemas.datacontract.org/2004/07/CTPCommerceDeployTests">127.0.0.1</CallingPartnerIpAddress>
<CallingPartnerName xmlns="http://schemas.datacontract.org/2004/07/CTPCommerceDeployTests">TEST</CallingPartnerName>
Ryan Thomas
  • 1,491
  • 2
  • 13
  • 23
  • This may help: https://stackoverflow.com/questions/37296273/how-to-set-soap-message-header-element-namespace-explicitly-in-net-wcf – Selim Yildiz Jul 07 '21 at 20:35

0 Answers0