0

I am trying to call one Web service through WCF, which is having USERNAME AND PASSWORD in SOAP Header.

I was able to create SOAP header in Client end, but have to test this from service end. Below is my generated SOAP Envelope from Fiddler.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">username</wsse:UsernameToken>
      <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">l5ZdykMOMh0c9FBMmuzj1mSDkII=</wsse:Password>
      <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">X3hHHJmJGpLQiv0otiPmEcuyZODKuG2N2luzQyRSx6XnNGqJlDtL+u72Xo1jnVzUEBZlA3BZxNOsE/CC6227hw==</wsse:Nonce>
    </wsse:Security>
  </s:Header>
  <s:Body>
    <GetData xmlns="http://tempuri.org/">
      <value>8</value>
    </GetData>
  </s:Body>
</s:Envelope>

But I am not getting how to develop to create the service for this. Means how this username and password will get verified at the service level.

Since I created normal WCF service, while I am passing the SOAP request I am getting the below error, but some how I have to make this service,and it should check the credentials passed in the SOAP request, and response has to sent back to the client.

Error : he content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' Fiddler Echo Service

Fiddler Echo Service


POST /Service1.svc HTTP/1.1 Content-Type: text/xml; charset=utf-8 VsDebuggerCausalityData: uIDPo4Ge0/7PGPVGuUnHA42gJlABAAAAg+i/3kLfaUmsO7qOZzeMmSRKTvecymdLlkjZ9CAeqTcACQAA SOAPAction: "http://tempuri.org/IService1/GetData&quot; Host: localhost:8888 Content-Length: 836 Expect: 100-continue Accept-Encoding: gzip, deflate Connection: Keep-Alive

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">username</wsse:UsernameToken><wsse:Password Type="http://docs.oasis-open.o'.

**EDITED:

My way of Trail :

I have to consume a service which is in SOAP(Web service) which is taking username token parameter.

  1. created stub for that basic behavior.
  2. Able to access the service without adding UserName token as described above.
  3. But getting the error after adding the Security token.

Now i want to update my service (stub) ,it should be able to accept SOAP request what i am passing as XML and Username and password validation should happen in the service based the SOAP request and i have to receive the response if authenticated.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Chiranjeevi
  • 161
  • 1
  • 4
  • 22
  • 1
    Always start from the simple and work up to the complex. Then you'll have your simpler successes to stand upon as you reach higher towards complexity. Do you know how to write a simple WCF service? Have you successfully done that? – John Saunders Jun 12 '15 at 20:47
  • @John: You are true, that way is always correct. i am a starter in wcf, but requirement is making to check the possibilities. and yes i am able to create a wcf applicaition. I am trying to create an environment(service) which is not available which is taking username and token.Let me Edit my question more clearly – Chiranjeevi Jun 13 '15 at 03:24
  • You should really tell us step by step what you did. Go down to the level of telling us exactly which commands you used. The idea is to give enough detail so that someone else could reproduce the exact same situation. – John Saunders Jun 13 '15 at 04:12

0 Answers0