I have seen many SO answers but non seem to help with the issue I have. What I am doing is calling a SOAP service from third party and it actually requires a prefix on element names. Example:
<pref:test>test</pref:test>
I have created a client using Add service reference in VS. I have a class which is where i want the prefix on each property.
public class WebsiteSoapHeader : System.Web.Services.Protocols.SoapHeader { public WebsiteSoapHeader() { xmlns.Add("test", "https://xxx/service"); } [XmlNamespaceDeclarations] public XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces(); [XmlElement(ElementName ="test",Namespace = "https://xxx/service")] public string testprop { get; set; } }
As this does not get serialized manually it only produces
<test xmlns="">test</test>