简体   繁体   English

.Net 2.0消耗WCF

[英].Net 2.0 consuming WCF

I am working on both the project using .Net 2.0 Web Application and also WCF. 我正在同时使用.Net 2.0 Web应用程序和WCF进行该项目。 If I use the WCF by its default configuration, when the .Net 2.0 project call its method, it throws an exception for unsupported SOAP message. 如果按默认配置使用WCF,则.Net 2.0项目调用其方法时,它将为不受支持的SOAP消息引发异常。

Goggled and found that people mentioned that WCF need to change the binding to BasicHttpBinding ->http://msdn.microsoft.com/en-us/library/ms731134.aspx 瞥了一眼,发现人们提到WCF需要将绑定更改为BasicHttpBinding-> http://msdn.microsoft.com/en-us/library/ms731134.aspx

Tried that and since I am hosting in IIS I did not do the BasicHttpBinding instantiation like the example shown below. 尝试过这一点,因为我是在IIS中托管的,所以没有像下面的示例那样执行BasicHttpBinding实例化。

// Create a BasicHttpBinding instance
BasicHttpBinding binding = new BasicHttpBinding();

However this time round, I can't even run the WCF service. 但是这次,我什至无法运行WCF服务。 When I run using right click, view in browser, I get a page with 使用右键单击运行时,在浏览器中查看,我得到一个页面

"Service name" has zero application (non-infrastructure) endpoints “服务名称”具有零个应用程序(非基础结构)端点

My web config for WCF is exactly same as the link I have given, only that I have changed the contract to suit my file. 我的WCF Web配置与我给出的链接完全相同,只是我更改了合同以适合我的文件。

Anyone with experience that care to help? 有经验的人愿意提供帮助吗? Thanks 谢谢

The web.config web.config

<system.serviceModel>
    <services>
      <service name="MyService" behaviorConfiguration="HttpGetMetadata">
        <endpoint address="" contract="MyContractName" binding="basicHttpBinding" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="HttpGetMetadata">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Yes, I just did that today. 是的,我今天才这样做。

  • Define the WCF service with BasicHttpBinding 使用BasicHttpBinding定义WCF服务
  • On your client, add web reference and it will create a SoapClient 在您的客户端上,添加Web参考,它将创建一个SoapClient
  • If you need security you need to use WSE 2.0 SP3. 如果需要安全性,则需要使用WSE 2.0 SP3。

My case had a requirement for clear-text username/password with SSL and I happily got it working using this . 我的案例要求使用SSL的纯文本用户名/密码,而我很高兴使用this来工作。

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

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