This question already has answers here:
Does this SOAP Fault mean what I think it means?
(3 answers)
Closed 8 years ago.
There is nothing too much to write here other than this error message :
SoapFault Object ( [message:protected] => Wrong Version [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\wamp\www\nsoap\phpclient.php [line:protected] => 10 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 10 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => getIMIPremium [1] => Array ( [0] => Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] => 23 [basicSumInsured] => 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [stateCode] => 233 ) ) ) ) ) [1] => Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 10 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] => 23 [basicSumInsured] => 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [stateCode] => 233 ) ) ) ) ) [previous:Exception:private] => [faultstring] => Wrong Version [faultcode] => VersionMismatch [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] => ( ! ) SoapFault: Wrong Version in C:\wamp\www\nsoap\phpclient.php on line 10 Call Stack #TimeMemoryFunctionLocation 10.0009674576{main}( )..\phpclient.php:0 20.0704702744SoapClient->getIMIPremium( )..\phpclient.php:10 )
Is it possible that there is an error in the client php code for it ? I have tried NuSoap, but it is also generating error that "Call error: Response not of type text/xml: application/wsdl+xmlHTTP/1.1 200 OK Date: Tue, 17 Sep 2013 16:55:39 GMT Server: Apache/2.2.22 (Win64) PHP/5.3.13 Last-Modified: Tue, 17 Sep 2013 13:18:39 GMT ETag: "a0000000a818c-12e9-4e69428b54054" Accept-Ranges: bytes Content-Length: 4841 Connection: close Content-Type: application/wsdl+xml ".
Do you know any fix for it ?
PHP Code :
<?php
try{
$client = new SoapClient("http://mysite.com/nsoap/IMIPremiumWebService.wsdl");
$args= array("imiPolicy" => array("expiryDate" => "23-09-2013", "imiInsured" =>array("item" => array("item" => array("age"=>'23', "basicSumInsured"=>'33233', "coverRageType"=>'12',"dateOfBirth"=>'26-09-1986',"preExistingDisease" => 'no'))), "inceptionDate"=>"12-09-2009" ,"noOfInsured"=>'1',"partnerCode" => '2121', "stateCode" => '233'));
$something = $client->getIMIPremium($args);
echo $client->responseData;
print_r($something);
}
catch (Exception $e)
{
echo "*****************";
print_r($e);
}
?>
You can find wsdl here (in my question related to NuSOAP:
WSDL Client Not Working
A little bit of googling with that particular error message reveals that it might be related to the Soap server answering in Soap version 1.2, while the default setting in PHP is Soap version 1.1.
Try adding an options array to the SoapClient with array('soap_version'=> SOAP_1_2) as the second parameter (see http://de1.php.net/manual/en/soapclient.soapclient.php for details).
Related
I'm accessing a mailbox using ddeboer/imap. Connecting to the Server and retrieving Messages ist not a problem. But $message->getHeaders() returns the following (shortened Version):
Ddeboer\Imap\Message\Headers Object
(
[storage:ArrayIterator:private] => Array
(
[date] => Fri, 5 Jul 2019 07:00:47 +0200
[subject] => Test Mail
[message_id] => <108a4850-284e-170a-2c7d-b6f9g5218202#test.de>
[fromaddress] => "Test" <test#test.de>
[from] => Array
(
[0] => stdClass Object
(
[personal] => Test
[mailbox] => test
[host] => test.de
)
)
[deleted] =>
[draft] =>
[msgno] => 1
[maildate] => 5-Jul-2019 07:00:49 +0200
[size] => 223715
[udate] => 1562302849
)
)
How am I supposed to access the Information e.g. udate or from->mailbox?
You can use the get method and add the path
$message->getHeaders()->get('udate'):
$message->getHeaders()->get('from')[0]->mailbox
Okay.. I did a lot of research but I kept getting errors so I decided to ask the question directly..
I always converted objects to arrays, but I now want to try using an object directly to save website speed.. I got this object:
stdClass Object
(
[date] => Wed, 8 Feb 2017 15:03:44 +0000
[Date] => Wed, 8 Feb 2017 15:03:44 +0000
[subject] => asdasdasd
[Subject] => asdasdasd
[message_id] =>
[toaddress] => "test#hotmail.com"
[to] => Array
(
[0] => stdClass Object
(
[personal] => test#hotmail.com
[mailbox] => test
[host] => hotmail.com
)
)
[fromaddress] => Jason K
[from] => Array
(
[0] => stdClass Object
(
[personal] => Jason K
[mailbox] => JasonK
[host] => hotmail.com
)
)
[reply_toaddress] => Jason K
[reply_to] => Array
(
[0] => stdClass Object
(
[personal] => Jason K
[mailbox] => JasonK
[host] => hotmail.com
)
)
[senderaddress] => Jason K
[sender] => Array
(
[0] => stdClass Object
(
[personal] => Jason K
[mailbox] => JasonK
[host] => hotmail.com
)
)
[Recent] =>
[Unseen] =>
[Flagged] =>
[Answered] =>
[Deleted] =>
[Draft] =>
[Msgno] => 1
[MailDate] => 8-Feb-2017 16:03:25 +0100
[Size] => 7887
[udate] => 1486566205
)
I am trying to get the first date (wed, 8 feb 2017), the from->mailbox and the Size. I managed to get the from->mailbox with this code:
foreach($EmailHeaders->from as $from ){
echo $from->mailbox;
}
But I just cant find out how to obtain the other values aswell.. If i try:
foreach($EmailHeaders as $headers){
echo $headers->date;
}
then it doesnt work... Can anyone explain this to me? Sorry if this is already asked a thousand times before, I just cant figure it out..
check this http://php.net/manual/en/function.get-object-vars.php
var_dump(get_object_vars($EmailHeaders ));
It's simple, you don't have to iterate over the direct properties, just use
$EmailHeaders->date
To get the "date", you just need to use $EmailHeaders->date
You don't need a foreach. It's working for "from" because it contains an array of objects.
You can simply do
$EmailHeaders->date
OR
$EmailHeaders->Date
to get the date from your object.
While iterating through loop, your pointer is already on the date item, so you can't point to date index. It will point to the date index under date item.
I got converted WSDL to PHP script but something is not working very I am trying to connect http://www.regcheck.org.uk/api/reg.asmx?wsdl, but getting this error
Array ( [RegCheckServiceCheck::Check] => SoapFault Object ( [message:protected] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at webtropy.CarReg.Check(String RegistrationNumber, String username) in c:\inetpub\wwwroot\regcheck.org.uk\api\reg.asmx:line 26 --- End of inner exception stack trace --- [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\xampp\htdocs\Check\RegCheckServiceCheck.php [line:protected] => 32 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\xampp\htdocs\Check\RegCheckServiceCheck.php [line] => 32 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => Check [1] => Array ( [0] => RegCheckStructCheck Object ( [RegistrationNumber] => [username] => [result:RegCheckWsdlClass:private] => [lastError:RegCheckWsdlClass:private] => Array ( ) [internArrayToIterate:RegCheckWsdlClass:private] => [internArrayToIterateIsArray:RegCheckWsdlClass:private] => [internArrayToIterateOffset:RegCheckWsdlClass:private] => ) ) ) ) [1] => Array ( [file] => C:\xampp\htdocs\Check\RegCheckServiceCheck.php [line] => 32 [function] => Check [class] => SoapClient [type] => -> [args] => Array ( [0] => RegCheckStructCheck Object ( [RegistrationNumber] => [username] => [result:RegCheckWsdlClass:private] => [lastError:RegCheckWsdlClass:private] => Array ( ) [internArrayToIterate:RegCheckWsdlClass:private] => [internArrayToIterateIsArray:RegCheckWsdlClass:private] => [internArrayToIterateOffset:RegCheckWsdlClass:private] => ) ) ) [2] => Array ( [file] => C:\xampp\htdocs\sample-regcheck.php [line] => 46 [function] => Check [class] => RegCheckServiceCheck [type] => -> [args] => Array ( [0] => RegCheckStructCheck Object ( [RegistrationNumber] => [username] => [result:RegCheckWsdlClass:private] => [lastError:RegCheckWsdlClass:private] => Array ( ) [internArrayToIterate:RegCheckWsdlClass:private] => [internArrayToIterateIsArray:RegCheckWsdlClass:private] => [internArrayToIterateOffset:RegCheckWsdlClass:private] => ) ) ) ) [previous:Exception:private] => [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at webtropy.CarReg.Check(String RegistrationNumber, String username) in c:\inetpub\wwwroot\regcheck.org.uk\api\reg.asmx:line 26 --- End of inner exception stack trace --- [faultcode] => soap:Server [detail] => ) )
I am sure something is missing in config files, mybe someone got idea ?
It's possible to call that web service via a HTTP GET request as follows;
<?php
$username = 'Your username here';
$regNumber = 'SK08KPT';
$xmlData = file_get_contents("https://www.regcheck.org.uk/api/reg.asmx/Check?RegistrationNumber=" . $regNumber ."&username=" . $username);
$xml=simplexml_load_string($xmlData);
$strJson = $xml->vehicleJson;
$json = json_decode($strJson);
print_r($json->Description);
?>
Not as elegant as a SOAP call, but simpler.
Script open source files
You can see all main files
https://www.wsdltophp.com/Wsdls/8a71627601a684624c5694104cce023f/RegCheck-1-0-1-1-1-1-0-0-0-0
I have a wsdl :
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:part element="impl:getIMIPremiumResponse" name="parameters">
</wsdl:part>
<wsdl:part element="impl:getIMIPremium" name="parameters">
</wsdl:part>
<wsdl:operation name="getIMIPremium">
<wsdl:input message="impl:getIMIPremiumRequest" name="getIMIPremiumRequest">
</wsdl:input>
<wsdl:output message="impl:getIMIPremiumResponse" name="getIMIPremiumResponse">
</wsdl:output>
</wsdl:operation>
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getIMIPremium">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getIMIPremiumRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getIMIPremiumResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:port binding="impl:IMIPremiumWebServiceSoapBinding" name="IMIPremiumWebService">
<wsdlsoap:address location="http://mysite.com/nsoap/IMIPremiumWebService.wsdl"/>
</wsdl:port>
And I want to submit information to get response. I created client.php which goes as follows :
<?php
try{
$client = new SoapClient("http://mysite.com/nsoap/IMIPremiumWebService.wsdl");
$args= array("expiryDate"=>'25',"imiInsured"=>'N',"inceptionDate"=>'43',"noOfInsured"=>'23',"partnerCode"=>'21',"stateCode"=>'MP' );
$something = $client->getIMIPremium($args);
echo $client->responseData;
}
catch (Exception $e)
{
print_r($e);
}
?>
But it is showing error in browser :
SoapFault Object ( [message:protected] => SOAP-ERROR: Encoding: object has no 'imiPolicy' property [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\wamp\www\nsoap\phpclient.php [line:protected] => 8 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 8 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => getIMIPremium [1] => Array ( [0] => Array ( [expiryDate] => 25 [imiInsured] => N [inceptionDate] => 43 [noOfInsured] => 23 [partnerCode] => 21 [stateCode] => MP ) ) ) ) [1] => Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 8 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [expiryDate] => 25 [imiInsured] => N [inceptionDate] => 43 [noOfInsured] => 23 [partnerCode] => 21 [stateCode] => MP ) ) ) ) [previous:Exception:private] => [faultstring] => SOAP-ERROR: Encoding: object has no 'imiPolicy' property [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] => ( ! ) SoapFault: SOAP-ERROR: Encoding: object has no 'imiPolicy' property in C:\wamp\www\nsoap\phpclient.php on line 8 Call Stack #TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php:0 20.0104698552SoapClient->getIMIPremium( )..\phpclient.php:8 )
Where am I wrong ? What should be possible solution for this?
Edit :
I have create a php file :
client.php
<?php
require_once('nusoap.php');
$client = new nusoap_client('http://localhost/nsoap/IMIPremiumWebService.wsdl', True);
$err = $client->getError();
if ($err) {
// Display the error
echo 'client construction error: ' . $err ;
} else {
$args= array("imiPolicy" => array("expiryDate" => "23-09-2013", "imiInsured" =>array("item" => array("item" => array("age"=>'23', "basicSumInsured"=>'33233', "coverRageType"=>'12',"dateOfBirth"=>'26-09-1986',"preExistingDisease" => 'no'))), "inceptionDate"=>"12-09-2009" ,"noOfInsured"=>'1',"partnerCode" => '2121', "stateCode" => '233'));
$answer = $client->call('getIMIPremium',
$args);
$err = $client->getError();
if ($err) {
// Display the error
echo 'Call error: ' . $err;
echo $client->response;
//print_r($client->response);
//print_r($client->getDebug());
} else {
echo "*******************";
print_r($answer);
}
}
?>
But it is generating this error :
Call error: Response not of type text/xml: application/wsdl+xmlHTTP/1.1 200 OK Date: Tue, 17 Sep 2013 15:10:38 GMT Server: Apache/2.2.22 (Win64) PHP/5.3.13 Last-Modified: Tue, 17 Sep 2013 13:18:39 GMT ETag: "a0000000a818c-12e9-4e69428b54054" Accept-Ranges: bytes Content-Length: 4841 Connection: close Content-Type: application/wsdl+xml
As per suggestion, I have added imiPolicy in $args :
$args= array("imiPolicy" => array("expiryDate" => "23-09-2013", "imiInsured" =>array("item" => array("item" => array("age"=>'23', "basicSumInsured"=>'33233', "coverRageType"=>'12',"dateOfBirth"=>'26-09-1986',"preExistingDisease" => 'no'))), "inceptionDate"=>"12-09-2009" ,"noOfInsured"=>'1',"partnerCode" => '2121', "stateCode" => '233'));
But now error becomes:
SoapFault Object ( [message:protected] => Wrong Version [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\wamp\www\nsoap\phpclient.php [line:protected] => 10 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 10 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => getIMIPremium [1] => Array ( [0] => Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] => 23 [basicSumInsured] => 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [stateCode] => 233 ) ) ) ) ) [1] => Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 10 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] => 23 [basicSumInsured] => 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [stateCode] => 233 ) ) ) ) ) [previous:Exception:private] => [faultstring] => Wrong Version [faultcode] => VersionMismatch [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] => ( ! ) SoapFault: Wrong Version in C:\wamp\www\nsoap\phpclient.php on line 10 Call Stack #TimeMemoryFunctionLocation 10.0012674576{main}( )..\phpclient.php:0 20.0184702744SoapClient->getIMIPremium( )..\phpclient.php:10 )
Like what was previously said..
The error is surrounding the follwoing:
[xdebug_message] => ( ! ) SoapFault: SOAP-ERROR: Encoding: object has no 'imiPolicy' property in C:\wamp\www\nsoap\phpclient.php on line 8 Call Stack #TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php:0 20.0104698552SoapClient->getIMIPremium( )..\phpclient.php:8 )
Let's pick this apart:
OAP-ERROR: Encoding: object has no 'imiPolicy' property in C:\wamp\www\nsoap\phpclient.php on line 8 Call Stack #TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php
and this breaks down to:
C:\wamp\www\nsoap\phpclient.php
on line 8 Call Stack #TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php
Is there a line/setting in the php file for: 'imiPolicy'
I think once that is set, you should be good-to-go.
Hope this helps.
Kent
I'm trying to create a custom product collection using Sandeep Shetty's shopify.php.
Ive been able to make other functional API calls- displaying products and carts etc. But Im unable to create a custom collection with a 'known-good' list of product ids.
Heres my code:
$charge = array
(
"custom_collection"=>array
(
"title"=>"ThisTest",
"collects"=>array(
"product_id"=>96525818,
"product_id"=>96393246
)
)
);
try
{
// All requests accept an optional fourth parameter, that is populated with the response headers.
$my_collect = $shopify('POST', '/admin/custom_collections.json', $charge, $response_headers);
// API call limit helpers
echo shopify_calls_made($response_headers); // 2
echo shopify_calls_left($response_headers); // 298
echo shopify_call_limit($response_headers); // 300
}
catch (ShopifyApiException $e)
{
echo "doh";
print_r($e);
}
}
I'm getting the following error back.
ShopifyApiException Object
(
[info:protected] => Array
(
[method] => POST
[path] => /admin/custom_collections.json
[params] => Array
(
[custom_collection] => Array
(
[title] => ToddTest
[collects] => Array
(
[product_id] => 96393246
)
)
)
[response_headers] => Array
(
[http_status_message] => Internal Server Error
[http_status_code] => 500
[server] => nginx
[date] => Mon, 16 Jul 2012 23:23:45 GMT
[content-type] => application/json; charset=utf-8
[transfer-encoding] => chunked
[connection] => keep-alive
[status] => 500 Internal Server Error
[x-shopify-shop-api-call-limit] => 18/500
[http_x_shopify_shop_api_call_limit] => 18/500
[cache-control] => no-cache
[x-request-id] => f22337df8773ff4fa2f9f384ca21f133
[x-ua-compatible] => IE=Edge,chrome=1
[set-cookie] => _secure_session_id=50f46da87f21f8a1b458baaf8e97a30a; path=/; secure; HttpOnly
[x-runtime] => 0.307888
)
[response] => Array
(
[errors] => Error
)
)
[message:protected] => Internal Server Error
[string:Exception:private] =>
[code:protected] => 500
[file:protected] => /home/lolsmg/www/shopify_pinterest/shopify.php
[line:protected] => 32
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /home/lolsmg/www/shopify_pinterest/pintrest_ui.php
[line] => 65
[function] => {closure}
[args] => Array
(
[0] => POST
[1] => /admin/custom_collections.json
[2] => Array
(
[custom_collection] => Array
(
[title] => ToddTest
[collects] => Array
(
[product_id] => 96393246
)
)
)
[3] => Array
(
[http_status_message] => Internal Server Error
[http_status_code] => 500
[server] => nginx
[date] => Mon, 16 Jul 2012 23:23:45 GMT
[content-type] => application/json; charset=utf-8
[transfer-encoding] => chunked
[connection] => keep-alive
[status] => 500 Internal Server Error
[x-shopify-shop-api-call-limit] => 18/500
[http_x_shopify_shop_api_call_limit] => 18/500
[cache-control] => no-cache
[x-request-id] => f22337df8773ff4fa2f9f384ca21f133
[x-ua-compatible] => IE=Edge,chrome=1
[set-cookie] => _secure_session_id=50f46da87f21f8a1b458baaf8e97a30a; path=/; secure; HttpOnly
[x-runtime] => 0.307888
)
)
)
)
[previous:Exception:private] =>
)
Im working from example code shopfiy provides but not getting very far. Thank you for any help.
Checking in the logs, it looks like the 'collects' attribute wasn't actually sent as an array which you specified in your $charge variable. After looking up the request_id f22337df8773ff4fa2f9f384ca21f133, this is the request you had sent:
{"custom_collection"=>{"title"=>"ToddTest", "collects"=>{"product_id"=>96393246}}}
The request should look like this to work:
{"custom_collection"=>{"title"=>"ToddTest", "collects"=>[{"product_id"=>96393246}]}}
Note that collects is an array.