Good morning, can you please help me, how can I enable ws-addressing in a web service so that they appear in the request header?
`<wsa:Action>`
`<wsa:MessagID>`
`<wsa:To>....`
My code in c#.
using System.ServiceModel;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System.Xml.Serialization;
namespace WebApplication2
{
[WebService(Namespace = "http://tempuri.org/")]
[ServiceContract(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : WebService
{
public ActionHeader ActionHeader;
public WebService1()
{
ActionHeader = new ActionHeader { Action = "http://test.com.co" };
}
[WebMethod]
[SoapHeader("ActionHeader", Direction = SoapHeaderDirection.In)]
public string GetTransactionInformationInvoice()
{
return "Bienvenido, WebServiceTest";
}
}
[XmlRoot(ElementName = "Action", Namespace = "wsa")]
public class ActionHeader : SoapHeader
{
[XmlText]
public string Action { get; set; }
}
}
I’m using XmlRoot to add the custom attribute however it doesn’t take the assigned value
I manage to obtain the wsa:action attribute in the header but it does not take the value that I assign, it remains “e gero” instead of http://test.com.co
`<wsa:Action>e gero</wsa:Action>`
As a result I must obtain the wsa attributes with their respective values in the request header, for example
<wsa:Action>http://www.test.com.co</wsa:Action>
I need the same function that SoapUI has with “Enable/Disable WS-A address”
to use the
<wsa:Action>
tag but directly in the code
Ricardo B. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.