6

最近まで、HP 保証情報の Web スクレイピングはうまく機能していましたが、ここ数週間で Web ページが変更され、新しいページで GET ではなく POST を使用しているようです。情報を URL に送信します。

私はこのページの解決策にいくつかの希望を見つけました:
http://ocdnix.wordpress.com/2013/03/14/hp-server-warranty-via-the-isee-api/
しかし、私は例を理解していませんこれまで Python を使用したことがないため、スクリプトを作成します。

また、Dell 保証の良い例を示すこの Web ページも見つけましたが、HP には、私が使用できる WSDL がありません。(リンクを投稿しますが、十分な担当者がいません)

これらの関数を使用して、リクエストを作成できます:
http://www.iislogs.com/steveschofield/execute-a-soap-request-from-powershell

すべてが期待どおりに機能すると思いますが、クライアントを登録するためのリクエストを作成するのに苦労しています。サーバーが壊れているか、リクエストが内部エラーを引き起こしていることを意味する 500 エラーが発生し続けます。

私はこれで初めて完全に途方に暮れました。

これを PowerShell で動作させたり、同様の問題を抱えている人はいますか?

22-10-13 更新

これでエンベロープができました。Python スクリプトを実行することができましたが、プロキシが原因で失敗したため、生成された XML を抽出しました。これは、どのように形成する必要があるのか​​ わからなかったので、必要なものでした。次のようになります。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:iseeReg="http://www.hp.com/isee/webservices/">
<SOAP-ENV:Body>
    <iseeReg:RegisterClient2>
    <iseeReg:request><isee:ISEE-Registration xmlns:isee="http://www.hp.com/schemas/isee/5.00/event" schemaVersion="5.00">
<RegistrationSource>
    <HP_OOSIdentifiers>
    <OSID>
        <Section name="SYSTEM_IDENTIFIERS">
        <Property name="TimestampGenerated" value="2013/10/22 09:40:35 GMT Standard Time"/>
        </Section>
    </OSID>
    <CSID>
        <Section name="SYSTEM_IDENTIFIERS">
        <Property name="CollectorType" value="MC3"/>
        <Property name="CollectorVersion" value="T05.80.1 build 1"/>
        <Property name="AutoDetectedSystemSerialNumber" value="10"/>
        <Property name="SystemModel" value="HP ProLiant"/>
        <Property name="TimestampGenerated" value="2013/10/22 09:40:35 GMT Standard Time"/>
        </Section>
    </CSID>
    </HP_OOSIdentifiers>
    <PRS_Address>
    <AddressType>0</AddressType>
    <Address1/>
    <Address2/>
    <Address3/>
    <Address4/>
    <City/>
    <Region/>
    <PostalCode/>
    <TimeZone/>
    <Country/>
    </PRS_Address>
</RegistrationSource>
<HP_ISEECustomer>
    <Business/>
    <Name/>
</HP_ISEECustomer>
<HP_ISEEPerson>
    <CommunicationMode>255</CommunicationMode>
    <ContactType/>
    <FirstName/>
    <LastName/>
    <Salutation/>
    <Title/>
    <EmailAddress/>
    <TelephoneNumber/>
    <PreferredLanguage/>
    <Availability/>
</HP_ISEEPerson>
</isee:ISEE-Registration></iseeReg:request>
    </iseeReg:RegisterClient2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

次に、次のように実行される Powershell スクリプトを作成しました。

function Execute-SOAPRequest {
Param (
[Xml]$SOAPRequest,
[String]$URL,
[switch]$UseProxy
)

write-host "Sending SOAP Request To Server: $URL" 
$soapWebRequest = [System.Net.WebRequest]::Create($URL) 
$soapWebRequest.Headers.Add("SOAPAction",'"http://www.hp.com/isee/webservices/RegisterClient2"') 

$soapWebRequest.ContentType = 'text/xml; charset=utf-8'
$soapWebRequest.Accept = "text/xml" 
$soapWebRequest.Method = "POST" 
$soapWebRequest.UserAgent = 'RemoteSupport/A.05.05 - gSOAP/2.7'

#$soapWebRequest.ServicePoint.Expect100Continue = $False
#$soapWebRequest.ServicePoint.MaxIdleTime = 2000
$soapWebRequest.ProtocolVersion = [system.net.httpversion]::version10

if($UseProxy){
    $soapWebRequest.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
}


write-host "Initiating Send." 
$requestStream = $soapWebRequest.GetRequestStream() 
$SOAPRequest.Save($requestStream) 
$requestStream.Close() 

write-host "Send Complete, Waiting For Response." 
$resp = $soapWebRequest.GetResponse() 
$responseStream = $resp.GetResponseStream() 
$soapReader = [System.IO.StreamReader]($responseStream) 
$ReturnXml = [Xml]$soapReader.ReadToEnd() 
$responseStream.Close() 

write-host "Response Received." 

return $ReturnXml 
} 

$SOAPRequest = [Xml](Get-Content 'C:\Temp\SoapEnv.xml')
$URL = 'https://services.isee.hp.com/ClientRegistration/ClientRegistrationService.asmx'

Execute-SOAPRequest $SOAPRequest $URL -UseProxy

しかし、今では500ではなく、追加のエラーが発生しています。エラーの詳細は次のとおりです。

Exception calling "GetRequestStream" with "0" argument(s): "The server committed a protocol violation. Section=ResponseStatusLine"
At C:\Temp\HP Register Client.ps1:29 char:54
+     $requestStream = $soapWebRequest.GetRequestStream <<<< () 
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
4

6 に答える 6

3

これを試して。. 私にとってはうまく機能します:注:リクエストタグのみをエスケープする必要があります。

$SOAPRequest= [xml]@"
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:iseeReg="http://www.hp.com/isee/webservices/">
<SOAP-ENV:Body>
    <iseeReg:RegisterClient2>
    <iseeReg:request>&lt;isee:ISEE-Registration xmlns:isee="http://www.hp.com/schemas/isee/5.00/event" schemaVersion="5.00"&gt;
&lt;RegistrationSource&gt;
    &lt;HP_OOSIdentifiers&gt;
    &lt;OSID&gt;
        &lt;Section name="SYSTEM_IDENTIFIERS"&g`enter code here`t;
        &lt;Property name="TimestampGenerated" value="2013/12/06 14:04:24 EST"/&gt;
        &lt;/Section&gt;
    &lt;/OSID&gt;
    &lt;CSID&gt;
        &lt;Section name="SYSTEM_IDENTIFIERS"&gt;
        &lt;Property name="CollectorType" value="MC3"/&gt;
        &lt;Property name="CollectorVersion" value="T05.80.1 build 1"/&gt;
        &lt;Property name="AutoDetectedSystemSerialNumber" value="10"/&gt;
        &lt;Property name="SystemModel" value="HP ProLiant"/&gt;
        &lt;Property name="TimestampGenerated" value="2013/12/06 14:04:24 EST"/&gt;
        &lt;/Section&gt;
    &lt;/CSID&gt;
    &lt;/HP_OOSIdentifiers&gt;
    &lt;PRS_Address&gt;
    &lt;AddressType&gt;0&lt;/AddressType&gt;
    &lt;Address1/&gt;
    &lt;Address2/&gt;
    &lt;Address3/&gt;
    &lt;Address4/&gt;
    &lt;City/&gt;
    &lt;Region/&gt;
    &lt;PostalCode/&gt;
    &lt;TimeZone/&gt;
    &lt;Country/&gt;
    &lt;/PRS_Address&gt;
&lt;/RegistrationSource&gt;
&lt;HP_ISEECustomer&gt;
    &lt;Business/&gt;
    &lt;Name/&gt;
&lt;/HP_ISEECustomer&gt;
&lt;HP_ISEEPerson&gt;
    &lt;CommunicationMode&gt;255&lt;/CommunicationMode&gt;
    &lt;ContactType/&gt;
    &lt;FirstName/&gt;
    &lt;LastName/&gt;
    &lt;Salutation/&gt;
    &lt;Title/&gt;
    &lt;EmailAddress/&gt;
    &lt;TelephoneNumber/&gt;
    &lt;PreferredLanguage/&gt;
    &lt;Availability/&gt;
&lt;/HP_ISEEPerson&gt;
&lt;/isee:ISEE-Registration&gt;</iseeReg:request>
    </iseeReg:RegisterClient2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
"@

保証 xml に対しても同じことを行う必要があるため、soap Web リクエストを再実行するだけです。

$hpgdid = $ReturnXml.envelope.body.RegisterClient2Response.RegisterClient2Result.Gdid
$hptoken = $ReturnXml.envelope.body.RegisterClient2Response.RegisterClient2Result.registrationtoken


$warrantyxml = [xml]@"
<SOAP-ENV:Envelope
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:isee="http://www.hp.com/isee/webservices/">
  <SOAP-ENV:Header>
    <isee:IseeWebServicesHeader>
      <isee:GDID>$hpgdid</isee:GDID>
      <isee:registrationToken>$hptoken</isee:registrationToken>
      <isee:OSID/>
      <isee:CSID/>
    </isee:IseeWebServicesHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <isee:GetOOSEntitlementList2>
      <isee:request>
        &lt;isee:ISEE-GetOOSEntitlementInfoRequest
    xmlns:isee="http://www.hp.com/schemas/isee/5.00/entitlement"
    schemaVersion="5.00"&gt;
  &lt;HP_ISEEEntitlementParameters&gt;
    &lt;CountryCode&gt;ES&lt;/CountryCode&gt;
    &lt;SerialNumber&gt;CZ10130050&lt;/SerialNumber&gt;
    &lt;ProductNumber&gt;519841-425&lt;/ProductNumber&gt;
    &lt;EntitlementType&gt;&lt;/EntitlementType&gt;
    &lt;EntitlementId&gt;&lt;/EntitlementId&gt;
    &lt;ObligationId&gt;&lt;/ObligationId&gt;
  &lt;/HP_ISEEEntitlementParameters&gt;
&lt;/isee:ISEE-GetOOSEntitlementInfoRequest&gt;
      </isee:request>
    </isee:GetOOSEntitlementList2>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
"@

$xmlstring = [string]$ReturnXml.Envelope.Body.GetOOSEntitlementList2Response.GetOOSEntitlementList2Result.Response

$warranty_info = [xml]@"
$xmlstring
"@

 $warranty_info."ISEE-GetOOSEntitlementInfoResponse"
于 2013-12-06T21:30:40.927 に答える
0

以下のように、転送される XML をエスケープする必要があります。また、TimestampGenerated も適切にフォーマットされていることを確認してください。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:iseeReg="http://www.hp.com/isee/webservices/">
<SOAP-ENV:Body>
    <iseeReg:RegisterClient2>
    <iseeReg:request>&lt;isee:ISEE-Registration xmlns:isee="http://www.hp.com/schemas/isee/5.00/event" schemaVersion="5.00"&gt;
&lt;RegistrationSource&gt;
    &lt;HP_OOSIdentifiers&gt;
    &lt;OSID&gt;
        &lt;Section name="SYSTEM_IDENTIFIERS"&gt;
        &lt;Property name="TimestampGenerated" value="2013/12/05 19:24:58 GMT"/&gt;
        &lt;/Section&gt;
    &lt;/OSID&gt;
    &lt;CSID&gt;
        &lt;Section name="SYSTEM_IDENTIFIERS"&gt;
        &lt;Property name="CollectorType" value="MC3"/&gt;
        &lt;Property name="CollectorVersion" value="T05.80.1 build 1"/&gt;
        &lt;Property name="AutoDetectedSystemSerialNumber" value="10"/&gt;
        &lt;Property name="SystemModel" value="HP ProLiant"/&gt;
        &lt;Property name="TimestampGenerated" value="2013/12/05 19:24:58 GMT"/&gt;
        &lt;/Section&gt;
    &lt;/CSID&gt;
    &lt;/HP_OOSIdentifiers&gt;
    &lt;PRS_Address&gt;
    &lt;AddressType&gt;0&lt;/AddressType&gt;
    &lt;Address1/&gt;
    &lt;Address2/&gt;
    &lt;Address3/&gt;
    &lt;Address4/&gt;
    &lt;City/&gt;
    &lt;Region/&gt;
    &lt;PostalCode/&gt;
    &lt;TimeZone/&gt;
    &lt;Country/&gt;
    &lt;/PRS_Address&gt;
&lt;/RegistrationSource&gt;
&lt;HP_ISEECustomer&gt;
    &lt;Business/&gt;
    &lt;Name/&gt;
&lt;/HP_ISEECustomer&gt;
&lt;HP_ISEEPerson&gt;
    &lt;CommunicationMode&gt;255&lt;/CommunicationMode&gt;
    &lt;ContactType/&gt;
    &lt;FirstName/&gt;
    &lt;LastName/&gt;
    &lt;Salutation/&gt;
    &lt;Title/&gt;
    &lt;EmailAddress/&gt;
    &lt;TelephoneNumber/&gt;
    &lt;PreferredLanguage/&gt;
    &lt;Availability/&gt;
&lt;/HP_ISEEPerson&gt;
&lt;/isee:ISEE-Registration&gt;</iseeReg:request>
    </iseeReg:RegisterClient2>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

XML を自分でエスケープする代わりの別のオプションは、解析されないように CDATA 内に配置することです: http://www.w3schools.com/xml/xml_cdata.asp

于 2013-12-05T19:48:13.240 に答える
0

公開されている URL に対して http POST を実行できない理由: http://h20564.www2.hpe.com/hpsc/wc/public/find

次のように curl で http POST を実行できます (たとえば、これをスクリプトに入れます)。

/usr/bin/curl ' http://h20564.www2.hpe.com/hpsc/wc/public/find ' \ --compressed \ -H ' Accept: text/html,application/xhtml+xml,application/xml ;q=0.9, / ;q=0.8' \ -H 'Accept-Encoding: gzip, deflate' \ -H 'Accept-Language: en-US,en;q=0.5' \ -H 'Connection: keep-alive ' \ -H 'ホスト: h20564.www2.hpe.com' \ -H 'リファラー: (欠落 https: ここ) h20564.www2.hpe.com/hpsc/wc/public/home' \ -H 'アップグレード-安全でない-Requests: 1' \ -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0' \ -H 'Content-Type: application/x-www-form -urlencoded' \ --data-binary '@/tmp/data' | grep hpui-標準テーブル

-H 'Cookie:' ヘッダーが必要な唯一の余分なもの。Web ルックアップから同じ Cookie をコピーできますが、どれくらいの期間使用できるかわかりません。

データ ファイルは /tmp/data にあり、次のようにフォーマットされています。

行[0].item.countryCode=US 行[0].item.serialNumber=XXXXXXXXX 行[1].item.countryCode=US 行[1].item.serialNumber=YYYYYYYYYY 行[2].item.countryCode=US行[2].item.serialNumber= 行[3].item.countryCode=米国 行[3].item.serialNumber= 行[4].item.countryCode=米国 行[4].item.serialNumber= 行[5 ].item.countryCode=米国行[5].item.serialNumber=行[6].item.countryCode=米国行[6].item.serialNumber=行[7].item.countryCode=米国行[7]. item.serialNumber= 行[8].item.countryCode=US 行[8].item.serialNumber= 行[9].item.countryCode=US 行[9].item.serialNumber= submitButton=送信

于 2016-10-26T23:19:41.493 に答える