【发布时间】:2011-06-20 16:05:56
【问题描述】:
我创建了一个服务,然后我看到一个页面说:
您已经创建了一个服务。
要测试此服务,您需要 创建一个客户端并使用它来调用 服务。您可以使用 命令行中的 svcutil.exe 工具 语法如下:
但是我如何判断它是 SOAP 还是 REST 服务呢?我如何从 wsdl 等中得知?
服务配置:
<services>
<service name="VLSContentService"
behaviorConfiguration="VLSContentServiceBehaviour" >
<endpoint name="rest"
address=""
behaviorConfiguration="VLSContentServiceEndpointBehaviour"
binding="webHttpBinding"
contract="IVLSContentServiceREST" />
<endpoint name="soap"
address="soap"
binding="basicHttpBinding"
contract="IVLSContentServiceREST"/>
</service>
</services>
更新:
嗨,马克,
我的配置是:
<services>
<service behaviorConfiguration="VLSContentServiceBehaviour" name="VLSContentService">
<endpoint name="rest" address="" behaviorConfiguration="VLSContentServiceEndpointBehaviour" binding="webHttpBinding" contract="IVLSContentServiceREST" />
<endpoint name="soap" address="soap" binding="basicHttpBinding" contract="IVLSContentServiceREST"/>
</service>
</services>
所以基本上我浏览到 .svc 文件并看到一个 wsdl 的链接。但是我怎么知道那是针对 SOAP 还是 REST 端点。我是否正确配置了它?
谢谢
更新时间:17:49(英国时间)
<system.serviceModel>
<!---Add the service-->
<services>
<service behaviorConfiguration="VLSContentServiceBehaviour" name="VLSContentService">
<endpoint name="rest"
address=""
behaviorConfiguration="VLSContentServiceEndpointBehaviour"
binding="webHttpBinding"
contract="IVLSContentServiceREST" />
</service>
</services>
<!---Add the behaviours-->
<behaviors>
<serviceBehaviors>
<behavior name="VLSContentServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="VLSContentServiceEndpointBehaviour">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
</system.serviceModel>
marc_s 更新:18:22(英国时间)
Pete,试试这个 - 没有元数据发布,什么都没有 - 只是 webHttpBinding - 你应该不要再看到任何 WSDL...
<system.serviceModel>
<services>
<service name="VLSContentService">
<endpoint name="rest"
address=""
binding="webHttpBinding"
contract="IVLSContentServiceREST" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
</system.serviceModel>
【问题讨论】:
-
完全没有 WSDL 的 RESTful!
-
是的,显然您得到了一个 WSDL - 因为您在服务配置中定义了一个 SOAP 端点 (
name=soap)! 尝试不使用basicHttpBinding端点 - 您将不会仅获取 REST 端点的 WSDL。 -
嗨,Marc_s,我想我们现在已经把我们的电线交叉了。我实际上已经取出了 SOAP 配置,但仍然得到了一个 wsdl。 Carlos 在下面的帖子中说这是因为我有
。 -
您仍然拥有元数据端点!您启用了“元数据交换”——这将发布一个 SOAP 端点....