Consuming wsdl using c# but getting error: “SOAP header To was not understood ”

北战南征 提交于 2019-12-25 02:18:15

问题


I am consuming wsdl using c# and I'm geting back the following error "SOAP header To was not understood".

What is causing this problem and how do I solve it?


Thanks for your response , According to your suggestion, i tried this code :

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

}

( I put also false on the mustUnderstand property ... )

I'm still get the same error message . "SOAP header To was not understood "

Any Idea ? Poli.


回答1:


Any time you get a "SOAP header X was not understood" it means that the MustUnderstand property for that element has been set to true and that the consuming application does not "understand" or recognize that element. The application that is sending the message is probably setting the MustUnderstand property because I think it is not set or false by default. see http://msdn.microsoft.com/en-us/library/system.servicemodel.messageheaderattribute.aspx



来源:https://stackoverflow.com/questions/7712616/consuming-wsdl-using-c-sharp-but-getting-error-soap-header-to-was-not-understo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!