Hi,
Can any one please tell how to pass Web Services Credentials(Web Services Username and Password) using WCF.
Inorder to Communicate with Web Services i have to provide username and password of the web services.
And There is no SoapAction in wsdl, and it has only one method.
The Request xml which i am passing is
<?xml version="1.0" encoding="UTF-8"?>
<ISO xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PassportPlus002.xsd ">
<SignonRq>
<SignonPswd>
<CustId>
<SPName>com.iso</SPName>
<CustPermId>xxx</CustPermId>
</CustId>
<CustPswd>
<EncryptionTypeCd>NONE</EncryptionTypeCd>
<Pswd>yyy</Pswd>
</CustPswd>
</SignonPswd>
<ClientDt>2005-02-23T10:18:25</ClientDt>
<CustLangPref>en-US</CustLangPref>
<ClientApp>
<Org> </Org>
<Name></Name>
<Version></Version>
</ClientApp>
</SignonRq>
<PassportSvcRq>
<SPName>com.iso</SPName>
<Quoteback>(Client Supplied Data)</Quoteback>
<PassportInqRq/>
</PassportsvcRq>
</ISO>
Here are the code and config file detais given.
Code:
XmlDocument requestXml = new XmlDocument();
requestXml.Load("c:\\NewRequest.XML");
string webserviceUrl = "https://xxxpassports.com/WebListener/services/SOAPListener";
string webserviceAction = "";
CustomBinding customBinding = new CustomBinding();
customBinding = new CustomBinding("HttpsSoap11Binding");
ChannelFactory<IRequestChannel> factory = new ChannelFactory<IRequestChannel>(customBinding, webserviceUrl);
IRequestChannel channel = factory.CreateChannel();
Message requestMessage = Message.CreateMessage(customBinding.MessageVersion , webserviceAction, new XmlNodeReader(requestXml));
Message responseMessage = channel.Request(requestMessage);
Response.Write(responseMessage.ToString());
Config File Details:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="HttpsSoap11Binding">
<textMessageEncoding messageVersion="Soap11"/>
<httpsTransport useDefaultWebProxy="true" transferMode="Buffered"/>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
And also we are using https in Web Service URL.
When i try running the above code, it gives the following error,
An exception of type 'System.ServiceModel.Security.MessageSecurityExcep tion' occurred in mscorlib.dll but was not handled in user code
Additional information: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="iso.com"'.