WCF合同优先 - 从WSDL /大量XSD创建服务

时间:2017-10-17 18:17:29

标签: c# web-services wcf svcutil.exe contract-first

我熟悉自下而上创建WCF服务(服务优先),但是,我的任务是尝试从一组WSDL(Contract-First)创建WCF服务。

我得到了一个名为'Schema'的文件夹,其中包含一组WSDL和一堆包含XSD文件的子文件夹(大量嵌套,大量XSD,一些XSD命名相同)。我所看到的大多数建议将所有XSD放在同一个文件夹中 - 但我不能这样做。

运行命令时 svcutil *.wsdl *.xsd /language:c# /out:"c:\temp\test.cs"我收到错误“输入路径'* .xsd'似乎没有引用我认为有意义的任何现有文件,因为Schema文件夹中没有.xsd。

  1. 这是正确的命令(我应该生成 / dataContract)?
  2. 当我有这个复杂的时候我怎么能生成 子文件夹的结构,嵌套的xsds和我无法把所有的 1个目录中的XSD?
  3. 更新

    我放弃使用svcutil并使用wscf.blue作为用户的建议。我现在遇到托管该服务的问题。我创建了一个名为eFileServiceLibrary的WCF服务库。

    服务类:

     public class Service1 : ICourtRecordMDEPort
        {
    
            public RecordFilingResponse RecordFiling(RecordFilingRequest request)
            {
                throw new NotImplementedException();
            }
    }
    

    合同类:

     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
        [System.ServiceModel.ServiceContractAttribute(Namespace="urn:oasis:names:tc:legalxml-courtfiling:wsdl:WebServicesProfile-Definitions-4.0", ConfigurationName="ICourtRecordMDEPort")]
        public interface ICourtRecordMDEPort
        {
                  ....
    

    App.config中:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's 
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="eFileServiceLibrary.ICourtRecordMDEPort">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8733/Design_Time_Addresses/eFileServiceLibrary/ICourtRecordMDEPort/" />
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint address="" binding="basicHttpBinding" contract="eFileServiceLibrary.ICourtRecordMDEPort">
              <!-- 
                  Upon deployment, the following identity element should be removed or replaced to reflect the 
                  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
                  automatically.
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
            <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>
    

    当我收到服务库时:WCF服务主机找不到任何服务元数据。这可能导致客户端应用程序运行不正常。请检查元数据是否已启用。你想退出吗?

    似乎mex端点存在且行为已启用servicemetadata。我还试图为我的行为添加一个name属性,并从service标签的behaviourconfiguration属性中引用它 - 仍然没有运气。

    非常感谢任何见解

0 个答案:

没有答案