必須從php
.
網址:https://testWS/CompanyGeneralInformation?IdUser=123&CUI=345
當查詢字串添加靜態時,它可以正常作業。
$out = file_get_contents("https://testWS/CompanyGeneralInformation?CUI=345&IdUser=123")
但是當預先計算并作為引數傳遞時,得到了錯誤
$id=123;
$qs="https://testWS/CompanyGeneralInformation?CUI=345&IdUser=".$id;
$out = file_get_contents($qs);
//but this is OK
//$qs="https://testWS/CompanyGeneralInformation?CUI=345&IdUser=123";
//$out = file_get_contents($qs);
錯誤:
Warning: file_get_contents(https://...CompanyGeneralInformation?IdUser=<?xml version="1.0" encoding="utf-8"?>
<int xmlns="http://tempuri.org/">123</int>&CUI=567)
: Failed to open stream: HTTP request failed! HTTP/1.1 400
注意:似乎 id 已從服務器端轉換為 XML ??? 當靜態始終有效時,更多使用 POST(通過 curl)的自定義引數會遇到相同的問題
通過 curl 發布(錯誤)
$str=strval("CUI=".$cui."&IdUser=".$id);
curl_setopt($ch, CURLOPT_POSTFIELDS,"$str"); //or either $str
System.Web.HttpRequestValidationException: A potentially dangerous Request.
Form value was detected from the client (IdUser="<?xml version="1.0" ...").
at System.Web.HttpRequest.ValidateString(String value, String collectionKey,
RequestValidationSource requestCollection) at
System.Web.HttpRequest.ValidateHttpValueCollection(HttpValueCollection collection,
RequestValidationSource requestCollection) at System.Web.HttpRequest.get_Form() at
System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) at
System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at
System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
注意:WS 檔案指定:
GET /link/CompanyGeneralInformation?CUI=string&IdUser=string HTTP/1.1
回應是 xml(但現在無關緊要)。
注意(錯誤來源)::Response is xml (but irrelevant now)
非常相關,因為在首先使用 WS 獲取 id 并且未轉換為變數后得到錯誤。然后 id 被傳遞(實際上是 xml,因為沒有決議)。
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
...
請讓我知道可能是什么問題。
uj5u.com熱心網友回復:
從您回顯的評論和提到的錯誤來看,這似乎只是一個問題,即在通過 URL 傳遞之前沒有從 XML 中提取所需資訊。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/507601.html
上一篇:激活受信任的身份提供程式/SAML提供程式后,無法使用集成Windows身份驗證訪問共享點Web服務
下一篇:為什么此Web服務代碼不輸出?