Reputation: 788
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 "\n\n";
echo $testclient->__getLastResponse();
echo "\n\n";
echo $testclient->__getLastResponseHeaders();
echo "\n\n";
} 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!
Upvotes: 3
Views: 8352
Reputation: 16143
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.
Upvotes: 1