我注意到使用此脚本:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$id = "idofadmin"
$pw = 'Admin123password'
$wsdl = "https://siteofwsdl.dom.com/services/MainService?wsdl"
$p = New-WebServiceProxy –Uri $wsdl
$p|Get-Member
$p.GetEntityFields(96)
返回wsdl的所有属性。但是,使用$ p.getEntityFields命令(和所有其他命令)将继续返回错误类型为“无法找到重载参数”的错误。该网站对getEntityFields命令有此说法。
<xs:element name="getEntityFields">
<xs:complexType>
<xs:sequence>
<xs:element name="sessionId" type="xs:string" minOccurs="0" nillable="true"/>
<xs:element name="entityTypeId" type="xs:long" minOccurs="0"/>
<xs:element name="mode" type="xs:long" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
该站点还提供了一个肥皂请求的示例,该请求通常会提取实体数据-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services">
<soapenv:Header/>
<soapenv:Body>
<ser:getEntityFields>
<ser:sessionId>F0C6EDD44B270B1F3DD0F1492A2A1585</ser:sessionId>
<ser:entityTypeId>96</ser:entityTypeId>
<ser:mode>1</ser:mode>
</ser:getEntityFields>
</soapenv:Body>
</soapenv:Envelope>
在powershell中需要什么才能对getEntityField命令发出代理请求?我正在猜测带有sessionID参数的p.getEntityFields之类的东西,因为它是我想要的特定参数,所以输入96,由于我只想“读取”它,所以输入模式类型0。如果正确,我如何获取会话ID? 顺便说一下,该站点使用的soap版本的输出是 响应(部分)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getEntityFieldsResponse xmlns:ns="http://services" xmlns:ax21="http://objects.services/xsd">
<ns:return xsi:type="ax21:ObjectMethod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax21:defaultValue xsi:nil="true"/>
<ax21:fieldLength>0</ax21:fieldLength>
<ax21:fieldSubTypeId>0</ax21:fieldSubTypeId>
<ax21:fieldTypeId>1</ax21:fieldTypeId>
<ax21:isRequired>false</ax21:isRequired>
<ax21:label>Alternate Resource</ax21:label>
<ax21:method>alternateResourceId</ax21:method>
<ax21:methodId>1131</ax21:methodId>
<ax21:onInsert>true</ax21:onInsert>
<ax21:onSelect>true</ax21:onSelect>
<ax21:onUpdate>true</ax21:onUpdate>
<ax21:sequence>0</ax21:sequence>
</ns:return>
<ns:return xsi:type="ax21:ObjectMethod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax21:defaultValue xsi:nil="true"/>
<ax21:fieldLength>0</ax21:fieldLength>
<ax21:fieldSubTypeId>0</ax21:fieldSubTypeId>
<ax21:fieldTypeId>1</ax21:fieldTypeId>
<ax21:isRequired>false</ax21:isRequired>
<ax21:label>Alternate Resource</ax21:label>
<ax21:method>alternateResourceByTitle</ax21:method>
<ax21:methodId>1160</ax21:methodId>
<ax21:onInsert>true</ax21:onInsert>
<ax21:onSelect>false</ax21:onSelect>
<ax21:onUpdate>true</ax21:onUpdate>
<ax21:sequence>9999</ax21:sequence>
</ns:return>
<ns:return xsi:type="ax21:ObjectMethod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax21:defaultValue xsi:nil="true"/>
<ax21:fieldLength>64</ax21:fieldLength>
<ax21:fieldSubTypeId>0</ax21:fieldSubTypeId>
<ax21:fieldTypeId>1</ax21:fieldTypeId>
<ax21:isRequired>false</ax21:isRequired>
<ax21:label>Base Calendar</ax21:label>
<ax21:method>initialBaseCalendarTitle</ax21:method>
<ax21:methodId>101101</ax21:methodId>
<ax21:onInsert>true</ax21:onInsert>
<ax21:onSelect>false</ax21:onSelect>
<ax21:onUpdate>true</ax21:onUpdate>
<ax21:sequence>0</ax21:sequence>
</ns:return>
<ns:return xsi:type="ax21:ObjectMethod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ax21:defaultValue xsi:nil="true"/>
<ax21:fieldLength>6</ax21:fieldLength>
<ax21:fieldSubTypeId>0</ax21:fieldSubTypeId>
<ax21:fieldTypeId>6</ax21:fieldTypeId>
<ax21:isRequired>false</ax21:isRequired>
<ax21:label>Billable Rate</ax21:label>
<ax21:method>targetBillingRate</ax21:method>
<ax21:methodId>1116</ax21:methodId>
<ax21:onInsert>true</ax21:onInsert>
<ax21:onSelect>true</ax21:onSelect>
<ax21:onUpdate>true</ax21:onUpdate>
<ax21:sequence>0</ax21:sequence>
</ns:return>
答案 0 :(得分:0)
我可以通过反复试验来回答这个问题-如果此处有多余的代码,请告诉我,我可以将其删除。但是以下内容确实适用于我尝试访问的wsdl。似乎这里不需要xmlsoap和invoke-webrequest,因为从新的WebServiceProxy开始的所有事情都是我们真正想要的。如果您输入不带任何()的命令,则实际上需要命令的参数。 PowerShell为您提供了预期的数据类型列表,迫使我在需要时使用类型[ref]。
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$id = "idoflogin"
$pw = 'adminpw'
$wsdl = "https://site.dom.com/services/MainService?wsdl"
$p = New-WebServiceProxy -Uri $wsdl -Credential $creds -Namespace Proxy
$sessionD = $p.login($id, $pw, $false, $false)
$p.getEntityFields($sessionD, '96', '0', '1', '0')
$p.logout($sessionD, [ref]$false, [ref]$false)