none
gSoap SecureConversation RRS feed

  • 问题

  • I am work at gSoap to develop a c++ client to communication with WCF web service. the WCF web service uses wsHttpBinding and the establishSecurityContext default is true, so I found the problem is here.
        the c++ client use gSoap generate some code with openssl and wsse plugin, but it throw the error information as below:

    the error code is 12

    SOAP 1.2 fault: SOAP-ENV:Sender ["http://schemas.xmlsoap.org/ws/2005/02/sc":BadContextToke

    n]

    "The message could not be processed. This is most likely because the action 'http://tempur

    i.org/IService1/GetData' is incorrect or because the message contains an invalid or expire

    d security context token or because there is a mismatch between bindings. The security con

    text token would be invalid if the service aborted the channel due to inactivity. To preve

    nt the service from aborting idle sessions prematurely increase the Receive timeout on the

     service endpoint's binding."

    Detail: [no detail]
    I have no idea on how to let it work and I have searched from google but found no some useful information. could you please give me some advice or point to how let the gSoap support the ws-secure conversation? All your reply is very appreciate.

    2011年10月17日 11:23

答案

全部回复

  • what is your service configuration?

     


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
     

    老徐的网站】:http://www.frankxulei.com/

    微软WCF中文技术论坛
    微软WCF英文技术论坛

    Windows Azure中文技术论坛

    2011年10月18日 8:30
    版主
  • below is my whole service configuration:
    btw, If set the establishSecurityContext=false, the c++ client works well. But the requirement should use it so as to no need to validate the username and password every time. So I suppose if the gSoap support the SecureConversation or not.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelMessageLoggingListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
          <source name="System.ServiceModel" switchValue="Verbose,ActivityTracing"
            propagateActivity="true">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelTraceListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add initializeData="C:\Users\jruan\Desktop\demoMsg.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
          <add initializeData="C:\Users\jruan\Desktop\demoTrace.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
        </sharedListeners>
        <trace autoflush="true" />
      </system.diagnostics>
      <system.serviceModel>
        <diagnostics>
          <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
            logMessagesAtTransportLevel="true" />
        </diagnostics>
        <services>
          <service name="WCF.Service1" behaviorConfiguration="WCF.Service1Behavior">
            <host>
              <baseAddresses>
                <add baseAddress="https://localhost:9000/"/>
              </baseAddresses>
            </host>
            <endpoint address=""
                      binding="wsHttpBinding"
                      contract="WCF.IService1"
                      bindingConfiguration="wsHttpBindingBehaviorConfiguration"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WCF.Service1Behavior">
              <serviceCredentials>
                <serviceCertificate findValue="WCFServerPK" storeLocation="LocalMachine"
                  storeName="My" x509FindType="FindBySubjectName" />
                <userNameAuthentication userNamePasswordValidationMode="Custom"
                  customUserNamePasswordValidatorType="WCFHost.MyUserNameValidator, WCFHost" />
              </serviceCredentials>
              <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:9001/metadata" />
              <serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="true"
                includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <wsHttpBinding>
            <binding name="wsHttpBindingBehaviorConfiguration">
              <reliableSession ordered="true" enabled="false" />
              <security mode="TransportWithMessageCredential">
                <transport clientCredentialType="None" />
                <message clientCredentialType="UserName" establishSecurityContext="true" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
      </system.serviceModel>
    </configuration>

    2011年10月20日 10:05
  •   <security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None" />
    <message clientCredentialType="UserName" establishSecurityContext="true" />
    </security>

    These Means That your service has to install a certificate for HTTPs protocol.

     


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
     

    老徐的网站】:http://www.frankxulei.com/

    微软WCF中文技术论坛
    微软WCF英文技术论坛

    Windows Azure中文技术论坛

    2011年10月21日 4:13
    版主