WCF二进制编码通过http

时间:2011-02-17 00:17:13

标签: wcf

我有一个我在Extranet场景中使用的WCF服务,但我想将其移动到Intranet场景,我在尝试使用二进制编码来获取消息时遇到问题。

当我尝试通过ChannelFactory调用服务时出现此错误:

  

内容类型应用程序/ soap + msbin1   服务不支持   http://cjm-dell-dev-pc/BoaService/BoaService.svc

服务配置:

<bindings>
   <customBinding>
      <binding name="BoaAppBinaryBinding">
         <binaryMessageEncoding />
         <httpTransport />
      </binding>
   </customBinding>
</bindings>
<services>
   <service behaviorConfiguration="ServBehave" name="AddressService">
      <endpoint address="http://localhost/BOAService/BoaService.svc"
          binding="customBinding" bindingConfiguration="BoaAppBinaryBinding"
          name="AddressService" contract="IAddressService" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
</services>
<behaviors>
   <serviceBehaviors>
      <behavior name="ServBehave">
         <serviceDebug includeExceptionDetailInFaults="true"/>
         <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" maxConcurrentInstances="100"/>
      </behavior>
   </serviceBehaviors>
</behaviors>

代码:

BindingElementCollection elements = new BindingElementCollection();   

elements.Add(new BinaryMessageEncodingBindingElement());     
elements.Add(new HttpTransportBindingElement());
var custBinding = new CustomBinding(elements);

EndpointAddress address = new EndpointAddress(new Uri("http://CJM-DELL-DEV-PC/BoaService/BoaService.svc", UriKind.Absolute));

var factory = new ChannelFactory<IAddressService>(custBinding, address);

IAddressService channel = factory.CreateChannel();

GetAddressReq req = new GetAddressReq();
req.AddressId = 2;

var addressRep = channel.GetAddress(req);

factory.Close();

尝试使用svcutil生成的代理时遇到同样的错误。

客户端配置

<system.serviceModel>
   <bindings>
      <customBinding>
         <binding name="BoaAppBinaryBinding">
            <binaryMessageEncoding />
            <httpTransport allowCookies="false"
                           bypassProxyOnLocal="false"                         
                           hostNameComparisonMode="StrongWildcard" 
                           maxBufferSize="65536"                          
                           maxBufferPoolSize="524288" 
                           maxReceivedMessageSize="65536"                          
                           transferMode="Buffered" useDefaultWebProxy="true" 
                           keepAliveEnabled="true"   />
         </binding>
      </customBinding>
</bindings>
<client>
   <endpoint name="AddressService"  
        address="http://localhost/BoaService/BoaService.svc"
        binding="customBinding" bindingConfiguration="BoaAppBinaryBinding"
        contract="IAddressService" />
</client>

先谢谢。 C Windows 7专业版 Visual Studio 2010

0 个答案:

没有答案