vpp*_*vpp 7 configuration wcf svcutil.exe
我有wcf服务.我尝试通过svcutil为客户端程序生成代理代码和配置文件:
svcutil http://localhost/WcfService2/Files.svc
Run Code Online (Sandbox Code Playgroud)
我有代理的有效文件,但没有得到配置文件.为什么?(VS2010 SP1,.NET 4.0,IIS 7.0)
我的服务合同:
[ServiceContract]
public interface IFiles
{
[OperationContract]
Guid UploadFile(Stream stream);
}
Run Code Online (Sandbox Code Playgroud)
我的网页配置:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="WebHttpBinding" maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="1073741824" transferMode="Streamed" />
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="WcfService2.Files">
<endpoint behaviorConfiguration="WebHttpBehavior" binding="webHttpBinding"
bindingConfiguration="WebHttpBinding" name="Files" contract="WcfService2.IFiles" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WebHttpBehavior">
<webHttp defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json"
automaticFormatSelectionEnabled="false" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.web>
<httpRuntime maxRequestLength="100000" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
使用WebHttpBinding(也称为WCF WebHttp端点)的端点不会像"普通"(即SOAP)端点那样公开元数据.WCF仍将为您的服务生成WSDL(自您指定<serviceMetadata httpGetEnabled="true"/>),但元数据将仅包含服务的某些方面(例如数据协定等).与Web相关的功能(WebInvoke/WebGet属性)将不在代理上,因此即使您获得代理文件,您也可能无法使用它与服务进行通信(除非您没有'使用其中任何一个).问题在于,没有广泛接受的格式来描述REST服务的元数据(WADL可能是最常用的,但它并不像SOAP的WSDL那样流行,而且它不是由WCF实现的).
简而言之:svcutil并不适用于Web端点.
如果你想要长版本:http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-aka-rest-endpoint -does -不work.aspx
| 归档时间: |
|
| 查看次数: |
9498 次 |
| 最近记录: |