使用SOAPUI测试wcf服务

时间:2016-03-23 16:22:32

标签: c# wcf soapui x509certificate wshttpbinding

我需要使用SOAPUI测试wcf wsHttpBinding服务。服务配置:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
  <baseAddressPrefixFilters>
    <add prefix="http://myserver/myservice/"/>
  </baseAddressPrefixFilters>
</serviceHostingEnvironment>

<behaviors>
  <endpointBehaviors>
    <behavior name="EPBehavior">
      <wsdlExtensions location="http://myserver/myservice/service.svc" singleFile="true" />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="Servicebehavior">
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpGetEnabled="true"/>
      <serviceCredentials>
        <clientCertificate>
          <authentication customCertificateValidatorType="myApp.ValidadorCertificado, myApp" certificateValidationMode="Custom" />
        </clientCertificate>
        <serviceCertificate findValue="Serial_of_service_certificate_here" x509FindType="FindBySerialNumber" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>

<services>
  <service behaviorConfiguration="Servicebehavior" name="myApp.myService">
    <endpoint address="/Java" behaviorConfiguration="EPBehavior"
      binding="wsHttpBinding" bindingConfiguration="ConfiguracionEnlaceJava"
      name="JavaEP" bindingNamespace="http://services.company.es/myservice"
      contract="myApp.myContract" />
  </service>
</services>

<bindings>
  <wsHttpBinding>
    <binding name="ConfiguracionEnlaceJava">
      <security>
        <message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<extensions>
  <behaviorExtensions>
    <add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  </behaviorExtensions>
</extensions>

如您所见,该服务将消息安全性与证书一起使用,并且还需要来自客户端的有效证书(使用自定义验证来验证它)。我已经阅读了这篇文章https://www.soapui.org/soapui-projects/ws-security.html,但无法让它适用于这种情况。 我在.Net工作的客户端,这是配置:

<system.serviceModel>
<behaviors>
  <endpointBehaviors>
    <behavior name="ClientCredentialsBehavior">
      <clientCredentials>
        <clientCertificate findValue="Serial_of_client_certificate_here" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySerialNumber" />
        <serviceCertificate>
          <authentication revocationMode="NoCheck" />
          <defaultCertificate findValue="Serial_of_service_certificate_here" storeLocation="LocalMachine" storeName="TrustedPeople" x509FindType="FindBySerialNumber" />
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>

<bindings>
  <wsHttpBinding>
    <binding name="BindingJavaEP">
      <security>
        <message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://myserver/myservice/service.svc/Java" behaviorConfiguration="ClientCredentialsBehavior"
    binding="wsHttpBinding" bindingConfiguration="BindingJavaEP"
    contract="myApp.myContract" name="JavaEP">
    <identity>
      <certificate encodedValue="base64_public_key_service_certificate_here" />
    </identity>
  </endpoint>
</client>

有人可以帮忙吗?

提前致谢。

0 个答案:

没有答案