How to create service for WSSE client in WCF

328 views Asked by At

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.

0

There are 0 answers