duanqiongchong0354 2011-04-12 20:18
浏览 325

在SoapClient中使用哪种方法(POST / GET)来发送HTTP请求?

I don't know if I'm asking a correct question! But I think its answer will guide me to solve my problem...

I'm trying to call a function by SoapClient,... It is a simplified version of my code:

class SOAP_AuthStruct {
    function __construct($user, $pass) {
        $this->Username = strval($user);
        $this->Password = strval($pass);
    }
}


$soap_loc = "SET TO SOAP PATH";

$soap_opts = array (
        'location'   =>  $soap_loc,
        'style'      =>  SOAP_DOCUMENT,
        'use'        =>  SOAP_LITERAL,
        'cache_wsdl' =>  WSDL_CACHE_NONE,
        'exceptions' =>  FALSE,
        'trace'      =>  TRUE
);


$testclient = new SoapClient("soapcall.wsdl", $soap_opts);

$soap_auth = new SOAP_AuthStruct("USERNAME", "PASSWORD");
$soap_header = new SoapHeader($soap_ns,'AuthHeader',$soap_auth,FALSE);

// $a_param is filled with essential values
$soap_param = array("CreateTransaction" => $a_param);


try {
    $result = $testclient->__soapCall("CreateTransaction", $soap_param, NULL, $soap_header, $output_headers);

    echo $testclient->__getLastRequest();
    echo "

";
    echo $testclient->__getLastResponse(); 
    echo "

";
    echo $testclient->__getLastResponseHeaders(); 
    echo "

";

} catch (SoapFault $fault) {

    trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);

}

I have a sample of correct request format, and the getLastRequest() function shows that the request has the correct format...

but in response I have this Error Message:

HTTP/1.1 405 Method Not Allowed
X-Mashery-Responder: XXXXX.mashery.com
Allow: GET, HEAD, OPTIONS, TRACE
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 12 Apr 2011 18:34:29 GMT
Accept-Ranges: bytes
Content-Length: 1293

I think (and I'm not sure about it!) that may be SoapClient use POST Method to send request, and I can't find it in the response header: "Allow: GET, HEAD, OPTIONS, TRACE"

Please let me know if you have any solution to my problem! and Also the answer to my question!

Many Thanks in advance for your help and your time ;)

--------------------------------------------

UPDATE:

OK, Now I know that it is sending POST Request!

I added this line to my code (after calling function)

echo $testclient->__getLastRequestHeaders();

and it returned:

POST /RimWebAPI/?api_key=APIKEY&sig=SIGNATURE   HTTP/1.1
Host: something.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.1.6
Content-Type: text/xml; charset=utf-8
SOAPAction: "SOAP ACTION"
Content-Length: 2344

I'm still working on it, but I would appreciate any help or quide!

  • 写回答

1条回答 默认 最新

  • doutuo1908 2011-04-12 21:51
    关注

    Is the Client HTTP POST calling the directory and not the script? I mean to say that it may be possible that /PATH_TO_API is a directory on the server and your script was index.php in that directory. In that case you will need to append a trailing slash to the POST command so that web-server would return the default document. What do the server logs say when you get the 405 error? Further, can you send the parameter as a GET instead of POST.

    评论

报告相同问题?

悬赏问题

  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?