customizing SOAP headers in C# mono

2019-08-30 09:26发布

问题:

How can I add custom SOAP headers to a webservice in Mono? I've used the following code:

[System.CodeDom.Compiler.GeneratedCodeAttribute("MonoDevelop", "2.6.0.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute
  (Name="CommonWebServicePortBinding", Namespace="http://mynamespace.com")]
public class CWebService : CommonWebService  
{   
    public CWebService ()
    {
        try
        {
            this.Url = "Url to wsdl";               
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString ());
        }
    }       

    protected override System.Xml.XmlWriter GetWriterForMessage (
      SoapClientMessage message, int bufferSize )
    {
        message.Headers.Add(My Custom Header goes here);
        return base.GetWriterForMessage(message, bufferSize);
    }   
}

but GetWriterForMessage hasn't been implemented in mono. Is there any other way?

回答1:

Apparently there's no way to customize Soap Headers in Mono and GetWriterForMessage throws NotImplementedException.



标签: c# mono