问题
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