【问题标题】:WCF / WSDL file seems to be malformedWCF / WSDL 文件似乎格式错误
【发布时间】:2015-06-13 23:30:08
【问题描述】:

好的。所以我有一个功能齐全的 WCF REST 服务。我可以使用 Fiddler 并将其发送 JSON 并获得预期的响应。

到目前为止一切顺利。

但是当我尝试在 .Net 项目中添加服务引用时,我在尝试创建服务时抛出错误(请参阅 Adding WCF Service Does Not Add Meaningful configuration.svc.info - 我想我已经找到了根本原因,但它完全不同我决定提出另一个问题。)

请注意,它不是 Visual Studio。我可以很好地添加对其他服务的引用,并且多个不同的 VS 安装无法与我的服务一起使用。

我认为根本原因是我的 WSDL 文件不正确。微软在这里提供了一个示例 - https://msdn.microsoft.com/en-us/library/windows/desktop/dd323317(v=vs.85).aspx 和一个现场示例 - http://www.webservicex.com/globalweather.asmx?wsdl

结果是这两个示例都比我在调用 WSDL 时拥有的更多 https://marius.activistmanager.com/1_0_0.svc?wsdl

但是当我使用单页 WSDL 时,我会得到各种信息 - https://marius.activistmanager.com/1_0_0.svc?singleWsdl

我认为问题出在我设置终点的 WCF 服务的 Web.config 文件中。

是否有人发现我的代码有问题会导致我在另一个问题中讨论的问题?我会很高兴发现我只是在做一些愚蠢的事情。

<client>
  <endpoint address="https://apitest.authorize.net/soap/v1/Service.asmx" binding="basicHttpBinding" bindingConfiguration="ServiceSoap" contract="AuthorizeNetCIMTest.ServiceSoap" name="ServiceSoap" />
</client>
<services>
  <service name="Marius.Marius_1_0_0" behaviorConfiguration="metadataSupport">
    <endpoint address="" behaviorConfiguration="Marius.MariusAspNetAjaxBehavior" bindingConfiguration="TransportSecurity" contract="Marius.Marius_1_0_0" binding="webHttpBinding" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>


<!--This is the transport the all the services use. It specifies that all the connections have to use HTTPS. Since there are no bindings for HTTP all those connections will 404-->
<bindings>
  <basicHttpBinding>
    <binding name="ServiceSoap">
      <security mode="Transport" />
    </binding>
    <binding name="ServiceSoap1" />
  </basicHttpBinding>
  <webHttpBinding>
    <binding name="TransportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </webHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="metadataSupport">
      <!-- Enables the IMetadataExchange endpoint in services that -->
      <!-- use "metadataSupport" in their behaviorConfiguration attribute. -->
      <!-- In addition, the httpGetEnabled and httpGetUrl attributes publish -->
      <!-- Service metadata for retrieval by HTTP/GET at the address -->
      <!-- "http://localhost:8080/SampleService?wsdl" -->
      <serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" httpsGetUrl="" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="Marius.MariusAspNetAjaxBehavior">
      <webHttp defaultOutgoingResponseFormat="Json" />
    </behavior>
  </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

【问题讨论】:

  • WSDL 仅适用于 SOAP。与服务引用相同。

标签: web-services visual-studio wcf wsdl


【解决方案1】:

John 是正确的 - 这是对问题的描述 (http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx)。看起来唯一的选择是使用 RestSharp 编写一些代码。呃。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-10
    • 2023-04-02
    • 1970-01-01
    • 2021-04-26
    • 1970-01-01
    • 1970-01-01
    • 2011-01-05
    • 1970-01-01
    相关资源
    最近更新 更多