WCF从类库-托管在IIS和wsdl生成

本文关键字:IIS wsdl 生成 类库 WCF | 更新日期: 2023-09-27 18:03:12

今天几乎一整天我都在尝试研究WCF,我的目标之一是手动创建一个WCF服务(或几乎这样)。

基于web上关于如何构建WCF应用程序的几篇文章,我创建了包含服务接口和实现项目的契约项目。两者都有Runtime。序列化

我创建了app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="FulFillmentServiceBehaviour">
                  <serviceMetadata httpGetEnabled="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="FulFillmentServiceBehaviour"
                name="Project.Services.Fulfillment">
                <endpoint address="http://localhost:8080/Services" binding="basicHttpBinding"
                    bindingConfiguration="" contract="P.Infrastructure.Services.IFulfillment" />
                <endpoint binding="mexHttpBinding" bindingConfiguration="" />
            </service>
        </services>
    </system.serviceModel>
</configuration>

1)如何在IIS中托管此服务我已经创建了一个虚拟目录,指向包含项目服务的文件夹(url http://localhost:8080/Services)

2)如何创建wsdl文件,以便我可以使用SOAPUI来测试它

我试着添加一个文件"履行"。Svc " with markup

<%@ ServiceHost Language="C#" Debug="true" Service="Project.Services.Fulfillment" CodeBehind="Fulfillment.cs" %>

用于测试,但它给出了错误

类型Project.Services。在ServiceHost指令中作为Service属性值提供的Fulfillment'找不到

更新1 * * * * * *

刚在网上找到这个,也许会有帮助。一个小问题是我需要网。配置

http://wncadmb026d.na-idm.na-gad.nec.com/Services/Fulfillment.svc?wsdl

更新2: * * * * *

SOAP UI能够生成SOAP请求,但是返回http 404作为响应…

http://www.aspfree.com/c/a/ASP.NET/Developing-a-WCF-Service-Library-and-Hosting-it-as-WCF-Web-Service-Using-VS2K8/

WCF从类库-托管在IIS和wsdl生成

我能够得到的帮助下,基本服务http://www.aspfree.com/c/a/ASP.NET/Developing-a-WCF-Service-Library-and-Hosting-it-as-WCF-Web-Service-Using-VS2K8/

http://msdn.microsoft.com/en-us/library/ms733766 (v =应用程序). aspx

我将服务模型部分从app.congig复制到web.config

我还必须将构建文件夹更改为/BIN而不是/BIN/debug/

明天早上会添加更多的代码

对于WSDL页面,您有正确的属性:

 <serviceMetadata httpGetEnabled="true" />

您可以通过在URL中添加?wsdl来访问它,例如http://localhost:8080/Service.svc?wsdl

至于错误,我认为问题是你没有使用。svc扩展名:

 <%@ ServiceHost Language="C#" Debug="true" 
  Service="Project.Services.Fulfillment" CodeBehind="Fulfillment.svc.cs" %>

您使用的是。svc文件,对吗?

如果您不使用.svc文件,可以使用路由,请参阅以下示例链接:http://geekswithblogs.net/michelotti/archive/2010/08/21/restful-wcf-services-with-no-svc-file-and-no-config.aspx