【发布时间】:2012-01-14 12:30:20
【问题描述】:
我有这个:
"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\bin\svcutil.exe" ^
/noLogo /t:code /l:cs /mc /tcv:Version35 /ct:System.Collections.Generic.List`1 /n:*,MYNS ^
/config:MyServiceProxy.config ^
/out:ServiceProxy.cs ^
https://remote-service/ServiceA?wsdl
它按照我的预期生成类、类型和端点配置。 当我添加多个端点时:
"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\bin\svcutil.exe" ^
/noLogo /t:code /l:cs /mc /tcv:Version35 /ct:System.Collections.Generic.List`1 /n:*,MYNS ^
/config:MyServiceProxy.config ^
/out:ServiceProxy.cs ^
https://remote-service/ServiceA?wsdl https://remote-service/ServiceB?wsdl https://remote-service/ServiceC?wsdl
MyServiceProxy.config 中没有端点,ServiceProxy.cs 中缺少所有 ServiceAWsClient() 方法。
更新:我删除了 /i 选项,因为它使类成为内部的。
更新:我现在可以生成两个 .cs 文件,如果我使用 /serializer:DataContractSerializer 选项,我得到了 ServiceAWsClient() 类,没有它我得到了共享类型。 有没有办法同时获得两者?
更新: 包含 ServiceAWsClient() 类的文件仍然不好。方法缺少参数。为什么? WSDL 包含:
<xs:element name="service" type="tns:service"/>
<xs:element name="serviceResponse" type="tns:serviceResponse"/>
<xs:complexType name="service">
<xs:sequence>
<xs:element name="context" type="ns1:GenericContext" minOccurs="0"/>
<xs:element name="userData" type="ns2:UserData" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="serviceResponse">
<xs:sequence>
<xs:element name="resultContext" type="ns1:GenericResponseContext" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
svcutil 生成:
public void service()
{
base.Channel.service();
}
什么时候应该:
public MYNS.GenericResultContext service(MYNS.GenericContext context, MYNS.ServiceA userData)
{
MYNS.service inValue = new MYNS.service();
inValue.context = context;
inValue.userData = userData;
MYNS.serviceResponse retVal = ((MYNS.ServiceA)(this)).service(inValue);
return retVal.resultContext;
}
ty!
【问题讨论】:
标签: wcf svcutil.exe