1

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

我得到了一个名为“Schema”的文件夹,其中包含一组 WSDL 和一堆包含 XSD 文件的子文件夹(很多嵌套,很多 XSD,一些 XSD 的名称相同)。我所看到的大部分内容都建议将所有 XSD 放在同一个文件夹中 - 但我不能这样做。

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

  1. 这是正确的命令(我应该使用 /dataContract 生成)吗?
  2. 当我有这种复杂的子文件夹结构、嵌套的 xsd 并且无法将所有 XSD 放在 1 个目录中时,如何生成?

更新:

我放弃了使用 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
    {
              ....

应用程序配置:

<?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>

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

似乎 mex 端点在那里,并且该行为启用了 servicemetadata。我还尝试为我的行为添加一个名称属性,并从服务标签的行为配置属性中引用它 - 仍然没有运气。

非常感谢任何见解

4

0 回答 0