此 WCF 错误的原因可能是什么?
我的 WCF 服务[使用 basicHttpBinding] 托管在 IIS 6 上。我能够在 IE 浏览器中的服务 url 中使用 ?wsdl 访问它。
我的 winforms 客户端中有一个表示层,我使用 VS.Net 中的 ServiceReferences 选项添加了该服务的引用,然后生成了一个代理。
当我调用此服务上的方法时,出现此异常。我在这里可能会缺少什么?谢谢。
“值不能为空。参数名称 uri。”在 System.ServiceModel.Description.ClientViaBehavior..ctor(Uri uri)
在 System.ServiceModel.Configuration.ClientViaElement.CreateBehavior() 在 System.ServiceModel.Description.ConfigLoader.LoadBehaviors[T](ServiceModelExtensionCollectionElement1 behaviorElement,KeyedByTypeCollection
1 行为,布尔值 常见行为)在 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint,字符串配置名称)
在 System.ServiceModel.ChannelFactory.ApplyConfiguration(字符串 配置名称)位于 System.ServiceModel.ChannelFactory.InitializeEndpoint(字符串 配置名称、EndpointAddress 地址)位于 System.ServiceModel.ChannelFactory
1..ctor(字符串 端点配置名称、端点地址远程地址)位于 System.ServiceModel.EndpointTrait
1.CreateSimplexFactory() 在 System.ServiceModel.EndpointTrait1.CreateChannelFactory() 位于 System.ServiceModel.ClientBase
1.CreateChannelFactoryRef(EndpointTrait1 端点特征)在 System.ServiceModel.ClientBase
1.InitializeChannelFactoryRef() 位于 System.ServiceModel.ClientBase`1..ctor() 位于 C:\Presentation\Service 中的TestingClient..ctor() References\ServiceReference1\Reference.cs:第 268 行
这是我的服务器和客户端的配置 xml:
*服务器:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ProviderBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="PTSWeb.PriceTestingService" behaviorConfiguration="PTSWeb.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="PTSWeb.IPriceTesting">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="PTSWeb.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
*客户端:
<system.serviceModel>
<client>
<endpoint address="http://localhost/PTSWeb/PTSWebService.svc"
behaviorConfiguration="PTSWeb.Service1Behavior" binding="basicHttpBinding"
bindingConfiguration="IPriceTestingBinding" contract="IPriceTesting"
name="IPriceTestingPort" />
<endpoint address="https://qaserver/webservice"
binding="basicHttpBinding" bindingConfiguration="ProviderBinding"
contract="Provider" name="ProviderPort" />
</client>
<bindings>
<basicHttpBinding>
<binding name="IPriceTestingBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
<binding name="ProviderBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="PTSWeb.Service1Behavior">
<clientVia/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在客户端配置行为中,您有一个未定义任何 URI 的 ClientVia 元素。删除此行为或定义 via Uri。
这很好地解释了客户端行为的目标和用法:http://blogs.msdn.com/b/anilkumargupta/archive/2009/05/16/wcf-intermediate-service- Between-client-and-server.aspx
In the client config behavior, you have a ClientVia element without any URI defined. Either remove this behavior or define the via Uri.
This quite well explain the goal and usage of the clientvia behavior : http://blogs.msdn.com/b/anilkumargupta/archive/2009/05/16/wcf-intermediate-service-between-client-and-server.aspx