asp.netwcfvisual-studio-2010asp.net-4.0

.net4.0 web app consuming java webservice requires Usernametoken Authentication


I am new to using .NET 4.0 VS2010. I need to consume Java webservice and send usernametoken custom authentication to access the service, this i did easily using WSE2.0 in VS2005 , what's the replacement for this in net 4.0 ?

My client is .NET 4.0 Asp.net web application(website) and service is Java webservice.

Alright after checking with Google uncle the following site was a good starting point

WCF Security

based on that I made few changes to my code but still not much joy. Here's the code:

protected void TPLoginButton_Click(object sender, EventArgs e)
{
    thirdpartyloginClient tplogin = null;
    ThirdPartyLogInResponse proxyresponse = null; 
    ThirdPartyLogInRequest proxyrequest = null;            
        
    try
    {
        if (tplogin == null)
        {
            tplogin = new thirdpartyloginClient();
        }
         
        if (proxyrequest == null)
        {
            proxyrequest = new ThirdPartyLogInRequest();
        }
        tplogin.ChannelFactory.Credentials.UserName.UserName = "abcd";
        tplogin.ChannelFactory.Credentials.UserName.Password = "sWwqHyCKMgjttlJEsQIvxzuBPTIBeVquZRPZqZdbDYDaOiHVxKuwYuYmQDVtqqBrBAlLiuOwWwQwOfTqSzOpyUaEbliOPaBHJTnBvulRSuZrcTHddKXwAIIxYDcuUmBJ";
            
        proxyrequest.username = "gauls";           
        proxyresponse = tplogin.ThirdPartyLogIn(proxyrequest);
    }
    catch 
    {
        if (proxyresponse != null)
        {
            ResultBoxResponse.Text = proxyresponse.result.resultMessage.ToString();
        }
        else
        {
            ResultBoxResponse.Text = "Empty response!!";
        }
    }
    finally
    {
        if (proxyresponse != null)
        {
                               ResultBoxResponse.Text = proxyresponse.result.resultMessage.ToString();
        }
        else 
        {
           
            ResultBoxResponse.Text = "Empty response!!";
        }
    }
}

my web.config looks like below

<system.serviceModel>    
    <bindings>
        <basicHttpBinding>
            <binding name="thirdpartyloginSoap11" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
      <!-- UsernameToken over Transport Security -->
      <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                    <message clientCredentialType="UserName" algorithmSuite="Default"/>
                </security>
            </binding>
        </basicHttpBinding>      
    </bindings>   
<client>      
  <endpoint address="http://11.2.2.16:6060/trydemo/ws/thirdpartylogin" binding="basicHttpBinding" bindingConfiguration="thirdpartyloginSoap11" contract="ThirdPartyLoginService.thirdpartylogin" name="thirdpartyloginSoap11"/>      
    </client>
</system.serviceModel>

Question is

How do I add timestamp and password as password digest?

The error I get now is

The provided URI scheme 'http' is invalid; expected 'https'.
Parameter name: via

I tried using clearusernamebinding

I get the following error

An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

my web.config file looks like this

<system.serviceModel> 
    <bindings> 
        <clearUsernameBinding>
            <binding name="myClearUsernameBinding" messageVersion="Soap11" />
        </clearUsernameBinding>
    </bindings>
    <client> 
        <endpoint 
            address=http://10.2.2.16:7070/demo/ws/thirdpartylogin
            binding="clearUsernameBinding" bindingConfiguration="myClearUsernameBinding"
            contract="ThirdPartyLoginService.thirdpartylogin" 
            name="ClearUsernameBinding_thirdpartylogin" 
        /> 
    </client> 
    <extensions>
        <bindingExtensions> 
            <add 
                name="clearUsernameBinding" 
                type="WebServices20.BindingExtenions.ClearUsernameCollectionElement, ClearUsernameBinding" 
            /> 
        </bindingExtensions> 
    </extensions> 
</system.serviceModel> 

"Receiver Requirement for Digested Password has not been met"strong text thats the actual error

How do I send password in the header as PasswordDigest?


Solution

  • You should use ClearUsernameBinding