Last post Mar 18, 2013 09:30 AM by mm10
Mar 12, 2013 05:26 AM|magoicochea|LINK
Hello I have the following problem. I need to consume a web service hosted by a 3rd party that requires my request to contain a user-agent on its header information, otherwise it will be rejected.
I generated the classes using the "Add Service Reference..." in Visual Studio 2010, but when I make a call the request does not have the information for user-agent. I can try to call the service using (HttpWebRequest)WebRequest.Create(), but then I have
to parse the xml result and it is a little bit tedious.
Is there any way to indicate the user-agent on the SoapClient class, because I can't seem to find the property that does that. Here is the code I'm using to test this:
public ActionResult Index(string email)
var serviceClient = new UserSoapClient("UserSoap");
CheckEmailRequest request = new CheckEmailRequest(email);
var isValid = serviceClient.CheckEmail(request);
ViewBag.ServiceOutput = isValid.CheckEmailResult? "Email is valid" : "Email is not valid";
Mar 18, 2013 09:30 AM|mm10|LINK
Create a message header and add it to the operation context:
MessageHeader messageHeader = MessageHeader.CreateHeader("header", "namespace", "value");
Or you could implement the IClientMessageInspector interface: