小编abc*_*123的帖子

如何使用非托管C++中的自定义绑定连接到WCF服务

我需要从本机C++应用程序连接到WCF服务.我尝试了下面的链接并且它可以使用wsHttpBinding.

为非托管C++客户端创建WCF服务

但是,我需要使用自定义绑定连接到WCF服务.这就是我的应用程序配置文件中自定义绑定的代码的样子

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="ResourceCenterEndpoint5">
          <mtomMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
            messageVersion="Default" maxBufferSize="65536" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192"      maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </mtomMessageEncoding>
          <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                    maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Ntlm"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    keepAliveEnabled="true" maxBufferSize="65536"
                    proxyAuthenticationScheme="Anonymous"
                    realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                    useDefaultWebProxy="true" />
        </binding>
      </customBinding>
      </binding>
    </bindings>
    <client>
      <endpoint address="http://usaabcxyzas1.na.abc.com/Build15/ReserSVC/Resource.svc"
      binding="customBinding" bindingConfiguration="ResourceCenterEndpoint5"
      contract="ServiceReference2.ResourceCenterServiceContract"
      name="ResourceCenterEndpoint5">
        <identity>
          <userPrincipalName value="devlts_srv@na.abc.com" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我有一个桥DLL,它是一个托管C++ DLL.托管C++ DLL将C#Client连接到本机应用程序.但是,由于Web服务使用自定义绑定,因此无法从托管C++ DLL连接到Web Service.我得到的错误是:

使用客户端身份验证方案"匿名"未授权http请求.从服务器收到的身份验证标头是"Negotiate,NTLM"

这就是我尝试从manged C++ dll连接到Webservice的方法:

Binding^ binding = gcnew BasicHttpBinding();

EndpointAddress^ …
Run Code Online (Sandbox Code Playgroud)

c# c++ wcf c++-cli

26
推荐指数
1
解决办法
4283
查看次数

标签 统计

c# ×1

c++ ×1

c++-cli ×1

wcf ×1