Как мне получить доступ к командам wsdl через powershell? - PullRequest
0 голосов
/ 06 декабря 2018

Я заметил, что с помощью этого скрипта:

[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?Я предполагаю что-то вроде p.getEntityFields с параметрами sessionID, 96, поскольку это именно тот, который я хочу, и режим типа 0, так как я хочу только «прочитать» его.Если это правильно - как я могу получить идентификатор сеанса?Кстати, выходной версии мыла, используемой на сайте, является Ответ (частичный)

<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>

1 Ответ

0 голосов
/ 07 декабря 2018

Я смог ответить на этот вопрос через несколько проб и ошибок - если здесь есть дополнительный код, дайте мне знать, и я смогу удалить его.Но следующее работает для 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)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...