确定。所以我有一个功能齐全的WCF REST服务。我可以使用Fiddler并将其发送给JSON并获得预期的响应。
到目前为止一切顺利。
但是当我尝试在.Net项目中添加服务引用时,我尝试创建服务时会抛出错误(请参阅Adding WCF Service Does Not Add Meaningful configuration.svc.info - 我认为我找到了根本原因但是它已经足够了不同的是,我决定打开另一个问题。)
请注意,它不是Visual Studio。我可以很好地添加对其他服务的引用,并且VS的多个不同安装将无法与我的服务一起使用。
我认为根本原因是我的WSDL文件不正确。 Microsoft在此处提供了一个示例 - 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" />
答案 0 :(得分:0)
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编写一些代码。啊。