none
Can anyone tell me how I can send username and password with soap message? RRS feed

  • Question

  • I have been working on interoperability with WSS4J with WCF.

    I'd like to ask a question on this forum because it has to do with WCF.

    I have WCF client which is supposed to send username and password. I listed the config file below.

     

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <diagnostics>
                <messageLogging logEntireMessage="true" logMalformedMessages="true"
                    logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
            </diagnostics>
            <bindings>
                <basicHttpBinding>
                    <binding name="stock-wss-01SoapBinding" 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" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:8383/axis/services/stock-wss-01"
                    binding="basicHttpBinding" bindingConfiguration="stock-wss-01SoapBinding"
                    contract="UsernameClient.StockQuoteService" name="stock-wss-01" />
            </client>
        </system.serviceModel>
    </configuration>

     

    When I run the main program listed below, I get an exception saying that "WSDoAllReceiver: Request does not contain required Security header"

    I checked out the soap message and it's not including username and pass in soap message.

    Any input would be greatly appreciated.

    namespace UsernameClient
    {
        class Program
        {
            static void Main(string[] args)
            {
                StockQuoteServiceClient service = new StockQuoteServiceClient();
                service.ClientCredentials.UserName.UserName = "test1";
                service.ClientCredentials.UserName.Password = "1tset";

                float result = service.getQuote("XXX");
                Console.WriteLine(result);
                service.Close();
            }
        }
    }

    Tuesday, February 13, 2007 8:56 AM

Answers

  • Hello:

    On your configuration, the mode attribute of the security element is set to 'None'. It must be set to 'Message'.

    Hope it helps
    Pedro Felix
    Tuesday, February 13, 2007 11:25 AM
    Moderator

All replies

  • Hello:

    On your configuration, the mode attribute of the security element is set to 'None'. It must be set to 'Message'.

    Hope it helps
    Pedro Felix
    Tuesday, February 13, 2007 11:25 AM
    Moderator
  • Thanks for the reply.

    I know WCF allows username/password to be sent only over https. But does that apply to a client too? or is it just for service?

     

    Wednesday, February 14, 2007 12:43 AM