在C#mono中自定义SOAP头

时间:2011-12-20 08:37:03

标签: c# mono

如何在Mono中将自定义SOAP标头添加到Web服务?我使用了以下代码:

[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);
    }   
}

GetWriterForMessage尚未在单声道中实现。还有其他办法吗?

1 个答案:

答案 0 :(得分:0)

显然,无法在Mono中自定义Soap Headers,GetWriterForMessage会抛出NotImplementedException。