使用c使用wsdl“但获取错误:”;“未理解到的SOAP头”;

使用c使用wsdl“但获取错误:”;“未理解到的SOAP头”;,soap,Soap,我正在使用c#使用wsdl,并返回以下错误 “未理解到的SOAP头” 造成此问题的原因是什么?如何解决 谢谢你的回复, 根据您的建议,我尝试了以下代码: using System; using System.Collections.Generic; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; [WebService(Namespace = "http://t

我正在使用c#使用wsdl,并返回以下错误 “未理解到的SOAP头”

造成此问题的原因是什么?如何解决


谢谢你的回复, 根据您的建议,我尝试了以下代码:

 using System;
 using System.Collections.Generic;
 using System.Web;
 using System.Web.Services; 
 using System.Web.Services.Protocols; 

 [WebService(Namespace = "http://tempuri.org/")]
 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

 public class MyHeader : SoapHeader
 {


 public bool _MustUnderstand;

public MyHeader() { }

public bool MustUnderstand
{
    get { return _MustUnderstand; }
    set { _MustUnderstand = value; }
 }

} 



public class Service : System.Web.Services.WebService
{
 public MyHeader MustUnderstand; 
public Service () 
{

    //Uncomment the following line if using designed components 
    //InitializeComponent(); 
}

[WebMethod]
[SoapHeader("MustUnderstand")]
public void Nokia()
{
    MustUnderstand = new MyHeader();
    MustUnderstand.MustUnderstand = true; 

    WebService connect = new WebService();

    long publicKeyK ;
    publicKeyK=        connect.GetPublicKey(out publicKeyK); 
}   

}
(我在mustUnderstand属性上也加了假…)

我仍然收到相同的错误消息。 “未理解到的SOAP标头”

有什么想法吗? Poli.

每当您得到“SOAP头X未被理解”时,这意味着该元素的MustUnderstand属性已设置为true,并且消费应用程序无法“理解”或识别该元素。发送消息的应用程序可能正在设置MustUnderstand属性,因为我认为它在默认情况下未设置或为false。

这个答案对我很有帮助。要从响应消息中删除
MustUnderstand
,您必须编写自己的
SoapFilter
,并重写
SoapFilterResult ProcessMessage(SoapEnvelope信封)
。在这里,您可以访问原始xml并删除所需的任何属性。然后,创建自己的类,该类派生自
SecurityPolicySertion
,并在
SoapFilter CreateClientInputFilter(FilterCreationContext上下文)
中使用过滤器。