我能够通过PowerShell New-WebServiceProxy
连接到WCF Web服务。我的Web服务包含3个端口类型。我的问题是-除第一个端口类型中的方法外,我无法调用其他任何方法。
我正在使用以下命令连接到WebService:
$ws = New-WebServiceProxy -Uri "http://server/myService.svc?wsdl"
我可以从WebService创建任何类的对象:
$obj = New-Object($ws.GetType().NameSpace + ".ClassName")
我可以从wsdl中的第一个端口类型调用方法:
$result = $ws.KontrahentDodaj($obj)
但是我不能从任何其他端口类型调用方法:
$result2 = $ws.FakturyLista($otherObject)
错误-方法调用失败,因为[]不包含名为'FakturyLista'的方法。
这是我的wsdl的片段:
<wsdl:portType name="IKontrahentService">
<wsdl:operation name="KontrahentDodaj">
<wsdl:input wsaw:Action="http://tempuri.org/IKontrahentService/KontrahentDodaj" message="tns:IKontrahentService_KontrahentDodaj_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IKontrahentService/KontrahentDodajResponse" message="tns:IKontrahentService_KontrahentDodaj_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="KontrahentZmien">
<wsdl:input wsaw:Action="http://tempuri.org/IKontrahentService/KontrahentZmien" message="tns:IKontrahentService_KontrahentZmien_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IKontrahentService/KontrahentZmienResponse" message="tns:IKontrahentService_KontrahentZmien_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="IFakturaService">
<wsdl:operation name="FakturaDodaj">
<wsdl:input wsaw:Action="http://tempuri.org/IFakturaService/FakturaDodaj" message="tns:IFakturaService_FakturaDodaj_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IFakturaService/FakturaDodajResponse" message="tns:IFakturaService_FakturaDodaj_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="FakturyLista">
<wsdl:input wsaw:Action="http://tempuri.org/IFakturaService/FakturyLista" message="tns:IFakturaService_FakturyLista_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IFakturaService/FakturyListaResponse" message="tns:IFakturaService_FakturyLista_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="ZalacznikiDoFakturyLista">
<wsdl:input wsaw:Action="http://tempuri.org/IFakturaService/ZalacznikiDoFakturyLista" message="tns:IFakturaService_ZalacznikiDoFakturyLista_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IFakturaService/ZalacznikiDoFakturyListaResponse" message="tns:IFakturaService_ZalacznikiDoFakturyLista_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
编辑:
使用命令$ws | gm -MemberType Method
后,我得到以下结果:
TypeName: Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1SERVICENAME_svc.BasicHttpBinding_IKontrahentService
Name MemberType Definition
---- ---------- ----------
Abort Method void Abort()
BeginKontrahentDodaj Method System.IAsyncResult BeginKontrahentDodaj(Microsoft.PowerShell.Commands.NewWebse...
BeginKontrahentZmien Method System.IAsyncResult BeginKontrahentZmien(Microsoft.PowerShell.Commands.NewWebse...
CancelAsync Method void CancelAsync(System.Object userState)
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)
Discover Method void Discover()
Dispose Method void Dispose(), void IDisposable.Dispose()
EndKontrahentDodaj Method Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceP...
EndKontrahentZmien Method Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceP...
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetType Method type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
KontrahentDodaj Method Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceP...
KontrahentDodajAsync Method void KontrahentDodajAsync(Microsoft.PowerShell.Commands.NewWebserviceProxy.Auto...
KontrahentZmien Method Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceP...
KontrahentZmienAsync Method void KontrahentZmienAsync(Microsoft.PowerShell.Commands.NewWebserviceProxy.Auto...
ToString Method string ToString()