标签: wshttpbinding

WCF错误未提供客户端证书.在ClientCredentials中指定客户端证书

我正在尝试调用WCF服务.我创建了一个自签名证书并安装在我的localmachine\personnal\certificates中,我也在我的部分中添加了.但我不明白为什么会出现此错误.

这是我的web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="wsHttpEndpoint">
                    <security mode="Transport">
                        <transport clientCredentialType="Certificate" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://abcdxyz.abc.syntax.com/TestCCService.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpEndpoint"
                contract="TestCCService.ITestCCService" name="wsHttpEndpoint" />
        </client>

        <behaviors>
            <endpointBehaviors>
                <behavior name="CustomBehavior">
                    <clientCredentials>
                        <clientCertificate findValue="abc.mymachine.name.com" x509FindType="FindBySubjectName"
                          storeLocation="LocalMachine" storeName="My" />
                        </clientCredentials>
                </behavior>
            </endpointBehaviors>
        </behaviors>

    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

但是当我尝试调用我的服务方法时抛出错误"未提供客户端证书.在ClientCredentials中指定客户端证书."

感谢您的建议以解决此错误?

wcf wshttpbinding

10
推荐指数
1
解决办法
2万
查看次数

在WCF客户端的代码中设置消息版本

我想将WSHttpBinding的消息版本设置为EnvelopeVersion.Soap11.我不知道该怎么做.谁能帮我.这是我的绑定代码

var binding = new WSHttpBinding()
        {
            UseDefaultWebProxy = true,
            Security =
            {
                Mode = SecurityMode.Transport,
                Transport =
                {
                    ClientCredentialType = HttpClientCredentialType.Basic
                },
            },
        };
Run Code Online (Sandbox Code Playgroud)

编辑:这是执行此操作的代码

TransportBindingElement transportElement = null;

        transportElement = new HttpsTransportBindingElement();

        ((HttpsTransportBindingElement)transportElement).AuthenticationScheme = AuthenticationSchemes.Basic;
        ((HttpsTransportBindingElement) transportElement).KeepAliveEnabled = false;

        var messegeElement = new TextMessageEncodingBindingElement
        {
            MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.None),
            ReaderQuotas =
                    {
                        MaxArrayLength = 200000,
                        MaxBytesPerRead = 200000,
                        MaxDepth = 200000,
                        MaxNameTableCharCount = 200000,
                        MaxStringContentLength = 200000
                    }
        };

        var binding = new CustomBinding(messegeElement, transportElement);
        return binding;
Run Code Online (Sandbox Code Playgroud)

wcf wshttpbinding wcf-client

9
推荐指数
1
解决办法
2万
查看次数

获取"无法通过绑定WSHttpBinding找到与端点的方案http匹配的基址.已注册的基址方案为[]"

我已经完成了Stack Overflow并且遵循 SSL和WebHttpBinding 的在线教程.

我收到了与那里提到的相同的错误.我已经恢复到旧的Web配置,如下所示.我的https网站工作正常,我添加了我的WCF作为网站的一部分,以避免打开一个新的端口.

当我收到错误时,我正试图达到类似的效果:

https://localhost/_vti_bin/TestingSQL/sample.svc/mex

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
<services>
  <service name="SharePointBits.Samples.WCFService.SampleService" behaviorConfiguration="SharePointBits.Samples.WCFService.SampleServiceBehavior">
<host> 
<baseAddresses> 
            <add baseAddress="https://testsite/_vti_bin/TestingSQL/Sample.svc"/> 
        </baseAddresses> 
    </host>

    <endpoint address="https://localhost/_vti_bin/TestingSQL/Sample.svc" binding="wsHttpBinding" contract="SharePointBits.Samples.WCFService.ISampleService" 
bindingConfiguration="wsHttpBindingEndpointBinding">
          <identity>
            <dns value="localhost"/>
      </identity>
  </endpoint>
  <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="SharePointBits.Samples.WCFService.SampleServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpsGetEnabled="true"/>
      <!-- To …
Run Code Online (Sandbox Code Playgroud)

wcf wshttpbinding

9
推荐指数
1
解决办法
4万
查看次数

使用wsHttpBinding的.NET Web服务可以被python使用

我遇到了问题,因为我有一个带有wsHttpBinding的Web服务:

<endpoint address="" binding="wsHttpBinding" contract="BindingTest.IService1" />
Run Code Online (Sandbox Code Playgroud)

我无法让我的python代码调用它,每次我尝试调用时都会收到此错误消息:

Exception: (400, u'Bad Request')
Run Code Online (Sandbox Code Playgroud)

经过多次调查并在互联网上搜索后,我只是在我的Web服务中指定了basicHttpBinding:

<endpoint address="basic" binding="basicHttpBinding" contract="BindingTest.IService1" />
Run Code Online (Sandbox Code Playgroud)

通过这种方式,我可以从python代码调用Web服务!

现在我的问题是另一个:我无法真正修改Web服务,我可以在本地尝试,但我没有权限修改它.

那么,有没有办法在python中指定一个"wsHttpBinding"请求?

这是我的实际代码:

import logging
from suds.client import Client
import sys
from suds.sax.element import Element

handler = logging.StreamHandler(sys.stderr)
logger = logging.getLogger('suds.transport.http')
logger.setLevel(logging.DEBUG), handler.setLevel(logging.DEBUG)
logger.addHandler(handler)

client =Client('Service_URL')
client.set_options(headers={'Content-Type': 'application/soap+xml; charset=utf-8'})
result = client.service.RouteDocument('Input')
Run Code Online (Sandbox Code Playgroud)

c# python basichttpbinding webservice-client wshttpbinding

9
推荐指数
0
解决办法
618
查看次数

具有证书的编程WCF消息安全性

我使用WSHttpBindings编写了一个自托管的WCF服务,我正在尝试使用我自己生成的证书来实现消息级安全性.不幸的是,我得到了一个隐藏的异常(通过服务跟踪查看器),说明"提供给包的凭据无法识别".

几个笔记:

  1. 这必须在代码中完成,而不是在配置中完成
  2. (服务器/客户端)证书是本地计算机存储中的证书,在调试时我的用户可以访问私钥.
  3. 我GOOGLE了地狱,这一点,并找到了一个很好的资源设置基于WCF消息安全在这里

我不确定我错过了什么.除了创建端点身份之外,大多数这些东西似乎都是直截了当的.无论是使用DnsEndpointIdentities,基于证书的,还是根本没有身份,它都会失败并显示相同的消息.

谁能指出我正确的方向?

服务器端:

var binding = new WSHttpBinding
    {
      Security =
      {
        Mode = SecurityMode.Message,
        Message = 
        {
          ClientCredentialType = MessageCredentialType.Certificate,
          AlgorithmSuite = SecurityAlgorithmSuite.Basic256Sha256Rsa15
        }
      }
    };

_host = new ServiceHost(this)
{
  Credentials =
  {
    ServiceCertificate =
    {
      Certificate = ServiceCert
    },
    ClientCertificate =
    {
      Certificate = ClientCert,
      Authentication =
      {
        TrustedStoreLocation = StoreLocation.LocalMachine,
        RevocationMode = X509RevocationMode.NoCheck,
        CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust
       }
    }
  }
};
var address = new Uri(string.Format(@"http://serviceaddress"));
var ep = _host.AddServiceEndpoint(typeof (IService), …
Run Code Online (Sandbox Code Playgroud)

wcf wshttpbinding x509certificate

8
推荐指数
1
解决办法
8992
查看次数

简单的WCF调用需要花费很多时间

我正在创建一个WCF服务器 - 客户端应用程序.但是,在我的第一次测试中,一个简单的调用(该方法基本上只return true;需要)需要很多时间(~5秒)

我试图追踪它,这是一个呼叫追踪的截图 在此输入图像描述

你可以看到第2行和第3行之间的时间是5秒(虽然老实说我不知道​​第2行和第3行是什么意思)

在客户端(调用者)配置中,绑定是这样的(主要由Visual Studio生成)

    <wsHttpBinding>
        <binding name="WSHttpBinding_IAgent" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="None">
          </security>
        </binding>
      </wsHttpBinding>
Run Code Online (Sandbox Code Playgroud)

并在服务器上

<wsHttpBinding>
    <binding name="WSHttpBinding_IAgent" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:05:00"
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="16777216" maxReceivedMessageSize="16777216"
      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
      allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="16777216"
        maxArrayLength="16384" maxBytesPerRead="16384" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="None"/>
    </binding>
Run Code Online (Sandbox Code Playgroud)

我称之为这样的方式

var client = new …
Run Code Online (Sandbox Code Playgroud)

.net debugging wcf soap wshttpbinding

8
推荐指数
1
解决办法
1623
查看次数

使用wsHttpBinding时,为什么InstanceContextMode.PerSession的行为与PerCall类似?

我有使用SOAP 1.2的AJAX客户端使用的WCF服务

Web.config文件:

<endpoint address="" binding="wsHttpBinding" 
contract="WcfService1.IService1" bindingConfiguration="wsHttpBin">

<wsHttpBinding>
  <binding name="wsHttpBin">
    <security mode="None"/>          
  </binding>
</wsHttpBinding>
Run Code Online (Sandbox Code Playgroud)

根据我的阅读,我必须使用,<security mode="None"/>因为使用"wsHttpBinding"绑定公开的服务实现了WS-*Web服务规范系列的WS-Security.由于绑定使用安全性,因此请求将被拒绝,因为AJAX不支持安全上下文.

我的WCF服务行为定义为InstanceContextMode.PerSession:

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, 
                 InstanceContextMode = InstanceContextMode.PerSession)]
Run Code Online (Sandbox Code Playgroud)

但是当我使用它时,该服务表现为PerCall,并且每次调用都会启动一个新的WCF实例,而不是使用当前实例.

使用wsHttpBinding时,为什么InstanceContextMode.PerSession的行为与PerCall类似?

我能做什么?

ajax wcf soap wshttpbinding wcf-sessions

8
推荐指数
1
解决办法
1963
查看次数

WCF:myservice.svc?wsdl显示"你已经创建了一个服务.",而不是WSDL?

我用wsHttpBinding和mexHttpBinding创建了一个WCF服务.在IIS6中的http上运行时,myservice.svc会显示通常的"您已创建服务".页.myservice.svc?wsdl显示包含WSDL的XML.

我改变<security mode="None"><security mode="Transport">,现在我尝试使用https来获得相同的服务.myservice.svc仍显示"您已创建服务".但myservice.svc?wsdl也显示"你已经创建了一个服务."

我究竟做错了什么?

该服务仍然有效(使用http时创建一个客户端,之后更改为https).但VS无法使用https生成新客户端,可能是因为?wsdl页面已损坏.

https wcf wsdl wshttpbinding

7
推荐指数
1
解决办法
2817
查看次数

客户端和服务器上都有证书的WCF(消息安全性和wsHttpBinding)

我正在尝试在客户端和服务器上使用证书身份验证设置WCF服务.我正在经历地狱,循环遍历所有可能的错误消息.

这里的最终目标是用证书对双方进行身份验证.我会为每个客户发出一份特定的证书,希望能让我分开.

到目前为止,我有以下配置文件:

服务器配置文件

<configuration>
    <system.serviceModel>
        <services>
            <service name="ServiceApiImplementation" behaviorConfiguration="myBehaviour">
                <host>
                    <baseAddresses><add baseAddress="http://localhost:9110/MyService"/></baseAddresses>
                </host>
                <endpoint address="" binding="wsHttpBinding" contract="IServiceAPI" bindingName="SOAP12Binding">
                    <identity>
                        <certificateReference findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/>
                    </identity>
                </endpoint>
            </service>
        </services>
        <bindings>
            <wsHttpBinding>
                <binding name="SOAP12Binding" receiveTimeout="00:02:00" closeTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00">
                    <security mode="Message">
                        <message clientCredentialType="Certificate" negotiateServiceCredential="false" establishSecurityContext="false" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="myBehaviour">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <serviceCredentials>
                        <serviceCertificate findValue="ServerCertificate" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName" />
                        <clientCertificate>
                            <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck"/>
                        </clientCertificate>
                    </serviceCredentials>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

客户端配置文件

<system.serviceModel>
    <client>
        <endpoint …
Run Code Online (Sandbox Code Playgroud)

wcf certificate wshttpbinding

7
推荐指数
1
解决办法
7171
查看次数

.NetStandard或.NET Core中的WSHttpBinding

我想将NMVS协议集成到我的应用程序中,该应用程序提供用于测试的wsdl文件,这些文件是在.net框架库中编写的示例代码。

我想在.netstandard,.netcore或UWP应用程序中对其进行测试,但wsdl文件仅支持“ WSHttpBinding”,而.netstandard,.net core和UWP不支持。

 <wsdl:binding name="WSHttpBinding_ISinglePackServices" type="ns:ISinglePackServices">



WSHttpBinding binding = new WSHttpBinding();
 binding.Security.Mode =  SecurityMode.Transport;
 binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
Run Code Online (Sandbox Code Playgroud)

我使用basichttpbinding,但出现错误,提示“内容类型为application / soap + xml;响应消息的charset = UTF-8与绑定的内容类型不匹配(text / xml; charset = utf-8)。 ”

还有什么其他方法可以解决此问题?

感谢Imrankhan

wshttpbinding uwp asp.net-core .net-standard

6
推荐指数
1
解决办法
2260
查看次数