简体   繁体   English

如何向不同的客户端公开 wcf 服务

[英]How to expose a wcf service to different clients

I am creating a wcf service.我正在创建一个 wcf 服务。 When i add the service as a "Web reference" to my web site (I do this by using the url: http://localhost/myservice.svc?wsdl ) and then call the web methods exposed by the service, I get a "Operation has timed out" exception.当我将服务作为“Web 引用”添加到我的网站时(我通过使用 url: http://localhost/myservice.svc?wsdl )然后调用服务公开的 Web 方法,我得到一个“操作已超时”异常。 However when i add the service as a "Service Reference" to the site, the calls work fine.但是,当我将该服务作为“服务引用”添加到站点时,调用工作正常。

The reason iam adding it as a web reference is, i want to expose the wcf service to all clients like java, php .....我将其添加为 Web 参考的原因是,我想将 wcf 服务公开给所有客户端,如 java、php .....

I have looked at the article in " http://blogs.msdn.com/juveriak/archive/2008/03/18/wcf-proxy-that-works-with-different-clients.aspx ", but i have not tried converting the wsdl to a typed proxy as suggested by this article.我看过“ http://blogs.msdn.com/juveriak/archive/2008/03/18/wcf-proxy-that-works-with-different-clients.aspx ”中的文章,但我还没有尝试过按照本文的建议将 wsdl 转换为类型化代理。

Any ideas on why i get a time out error when using it as a web reference?关于为什么在将其用作网络参考时出现超时错误的任何想法?

Likely you're using WsHttpBinding rather than BasicHttpBinding .您可能正在使用WsHttpBinding而不是BasicHttpBinding .NET 2.0 web services cannot consume a WsHttpBinding service. .NET 2.0 Web 服务不能使用WsHttpBinding服务。

The problem is one of protocol.问题是协议之一。 Web service protocols are constantly changing, adding security, federated identity, and so forth. Web 服务协议不断变化,增加了安全性、联合身份等。 As they change, older technologies can't communicate using the newer protocols.随着它们的变化,旧技术无法使用新协议进行通信。

Thankfully, WCF will allow you to use multiple protocols in a single service -- just set up separate endpoints for each protocol you want to use.幸运的是,WCF 将允许您在单个服务中使用多个协议 —— 只需为要使用的每个协议设置单独的端点。 Be wary, however, as some are more secure than others.但是要小心,因为有些比其他更安全。

Regarding versioning, the MessageVersion class is a good starting point.关于版本控制, MessageVersion类是一个很好的起点。

Edit: I should have mentioned that you need to use MessageVersion as part of a custom TextMessageEncodingBindingElement binding, like so:编辑:我应该提到您需要使用MessageVersion作为自定义TextMessageEncodingBindingElement绑定的一部分,如下所示:

<bindings>
    <customBinding>
        <binding name="MyBinding">
            <textMessageEncoding messageVersion="Soap11WSAddressing10"/>
            <httpTransport/>
        </binding>
    </customBinding>
</bindings>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM