I'm trying to setup a data request for a site, but, am running into a problem when trying to pull the data.
I tested the url and credentials using http://www.soapclient.com/soaptest.html and it works perfectly so I know the service is up and the correct credentials are being entered, but, when using the code below, I'm given the following error;
Fatal error: Uncaught SoapFault exception: [Invalid Login] in...
The full code (except generalized URL) that I'm using to make the request is;
<?php
$client2 = new SoapClient("http://www.example.com/api/soap.php?wsdl", array('trace'=> true));
$results2 = $client2->boxInfo(array(
"customer" => 'XBLK',
"size" => "four",
"price" => "twenty"));
echo "<pre>";
var_dump($client2-> __getLastRequestHeaders());
var_dump($client2-> __getLastRequest());
var_dump($client2-> __getLastResponseHeaders());
var_dump($client2-> __getLastResponse());
var_dump($results2);
echo "</pre>";
?>
As I'm new to these calls, I'm not sure if I missed something with the SOAP installation when I updated php (I verified it's installed and enabled) or if I've just been staring at the code so long that I'm simply missing something obvious.
It's a client issue if it works elsewhere. Try using an object to hold the parameters instead of an array:
$params = new stdClass();
$params->customer = 'XBLK';
$params->size = 'four';
$params->price = 'twenty';
$results2 = $client2->boxInfo($params);
Related
I'm stuck on a "simple" stripe integration problem. I have a checkout page where the amount can change on the checkout page, so the paymentIntent needs to change after the amount does. I created a short php app that is IDENTICAL to the one that successfully creates the paymentIntent, but now I'm updating the paymentIntent. I successfully pass in the new cost and the payment intent id to the app. But when I execute the ONE LINE of code to do the update, the fetched php doc throws an error 500. I comment out that ONE LINE and I don't get the error. I tried uploading it to a secure server thinking that was it (but I can run the create.php on my localhost without a problem) that didn't fix it either. I've been working on this for 10 hours and need to get it done tonight. Do you think you could help? here's the code:
\Stripe\Stripe::setApiKey('sk_test_xxx...'); // I have the correct secret key
header('Content-Type: application/json');
try {
// retrieve JSON from POST body
$json_str = file_get_contents('php://input');
$json_obj = json_decode($json_str);
$cost = $json_obj->c;
$paymentId = $json_obj->pi;
\Stripe\PaymentIntent::update(
$paymentId,
['amount' => $cost]
);
$output = [
'amount' => $stripe->amount,
];
echo json_encode($output); // to verify that it changed it
} catch (Error $e) {
http_response_code(500); // even if I comment this line out, i get error 500
echo json_encode(['error' => $e->getMessage()]);
}
::solved::
Ok, my stupid fault. The docs are a little unclear. It has you store the client_secret to actually do the charge later. To update a paymentIntent, you need to pass the paymentIntentId. They start with the same long string of letters and I thought they were the same.
$FM_CONNECT = array(
'DB_FILE' => 'webaccess'
);
require_once "__app/dbConnect/FM.php";
require_once "__app/environmentSettings/environmentSettings.php";
$layout = 'webAccess';
$findCommand =& $fm->newFindCommand($layout);
$findCommand->addFindCriterion('AccountName', $_POST['username']);
$result = $findCommand->execute();
if(FileMaker::isError($result)){
FMExit(array(
'code' => 1,
'mes' => $result->getMessage()
));
}
$records = $result->getRecords();
When I try send some request to FileMaker server it return.
"XML error: Not well-formed (invalid token) at line 1"
I haven't change the code for a few weeks and I didn't see this error before.
Has anyone else experienced something like this?
This looks like FileMaker php api. If it is the case, you are missing the connection. If you just omitted the connection code from your code (since you get the error from the server), look at your request and check that XML is well formed. I can't check the request as you did not post it.
Make sure the web publishing engine is started and working. I faced this problem already and in my case the WPE was stopped suddenly. I started the WPE from the admin console and it was fine.
I am working on an api for a client. I have received the following information:
API Url: http://xyz-crm.example/WebAPI/Custom/project_name/XML/
Username: foobar
password: spameggs
I need to configure the PHP SOAP client for the same in non-WSDL mode. I have written the following but it does not seem to work:
$wsdl = null;
$options = array(
'uri' => 'http://xyz-crm.example/WebAPI/Custom/project_name/XML/',
'location' => 'http://xyz-crm.exmaple.com/WebAPI/Custom/project_name/XML/',
'login' => 'foobar',
'password' => 'spameggs'
);
$client = new SoapCLient($wsdl, $options);
I just want to make a successful ping to the api at first. See if things are working fine. What am I doing wrong here?
Update 1
I made the following changes:
$wsdl = null;
$options = array(
'uri' => "http://xyz-crm.example/WebAPI/Custom/project_name/XML/",
'location' => "http://xyz-crm.example/",
'Username' => "foobar",
'Password' => "spameggs",
'soap_version' => '1.2'
);
$client = new SoapClient($wsdl, $options);
$client = $client->getListings();
I get the error: looks like we got no XML document
[Edit by me, hakre: This update was done as feedback to answer #1. It changes the location option using a shortened URL (reason not given by OP) and it adds the soap_version option (as suggested in answer #1, but not as constant but as string (containing an invalid value), so there should be no wonder this creates an error, a correct option value is given in answer #1 (the SOAP_1_1 constant) and by intention, the correct value would be the SOAP_1_2 constant for this example). Error message as commented by OP was "SOAP Fault: Wrong version."]
Update 2
I tried the following but it still fails:
$listing = $client->getListings();
$request = $client->__getLastRequest();
The execution stops at the first line itself without ever going to the second one.
[Edit by me, hakre: As review has shown wrong configuration options in Update 1 already which are not addressed in Update 2 it would be a miracle if it still wouldn't fail. The execution stops because an Exception is thrown and no error/exception handling is done]
Die URI or file ending does not matter, it could even be .jpg, there is no default.
Have a look at similiar questions: Does this SOAP Fault mean what I think it means?
It would be helpful if you put the error message into the question, aswell as the XML output of your request.
try setting the SOAP Version in the array of your SoapClient instance to one of the constants (try different ones):
new SoapClient($url, array("soap_version" => SOAP_1_1,.......
or SOAP_1_2 ...
To debug the XML try the answer from Inspect XML created by PHP SoapClient call before/without sending the request
The error message of your updated question does not look like it coming from PHP, looks more like an answer from the webservice, means your request is actually working.
I am feebly trying to implement a stamps.com api interface into my platform. This is my first time using SOAP, I event had to recompile PHP to enable the libraries.
I'm moving along but now I'm having a problem. They support soap 1.1 and soap 1.2 requests, and when I run the following code:
$client = new SOAPClient(
'./SWSIM.wsdl',
array(
'trace' => 1
)
);
I get back a successful response from my request that comes after this.
However if I add the option to use soap 1.2 like this:
$client = new SOAPClient(
'./SWSIM.wsdl',
array(
'trace' => 1,
'soap_version' => SOAP_1_2
)
);
I get the following error:
There was an exception running the extensions specified in the config file. ---> Value cannot be null. Parameter name: input
This line is not actually throwing the exception. Its the following command that throws it, but removing the soap_version is what "fixes it". I would like to use soap 1.2 so naturally this is bugging me.
FTR The command I'm running is this:
$authData = array(
"Credentials" => array(
"IntegrationID" => "MYUID",
"Username" => "MYUSERNAME",
"Password" => "MYPASSWORD"
)
);
try {
$objectresult = $client->AuthenticateUser($authData);
} catch (Exception $e) {
echo "EXCEPTION: " . $e->getMessage();
print_r($e);
exit;
}
The WSDL file can be viewed here:
https://swsim.stamps.com/swsim/swsimv22.asmx?wsdl
I have also checked in with their developer support and they said:
"The message you are currently receiving is returned from whichever program you are designing your integration with. This has been commonly noted happening within Visual Basic where is creates a wrapper class that needs certain variables for the response. This could be similar to the behavior that you are experiencing. Please verify how your program language consumes a WSDL."
I also noticed that the __soapCall method excepts an "input headers" argument. I'm not entirely sure I should be / can even use that method in my code. I suppose I should just try and play with it.
Check your WSDL file. I was using the wrong one, and it appears you may be as well. Try this one: http://developer.stamps.com/developer/downloads/files/Stamps.com_SWSIM.wsdl
NOTE: The above is out of date. Contact stamps.com for the current wsdl!
I know this is an old thread, but here is an example class that should get anyone started with the stamps.com api in php https://github.com/aaronjsmith/stamps.com-php
The WSDL looks fine and it's the same input structure for both Soap versions. The problem is a bug somewhere at their end, you'll have to contact them to resolve.
I would also test it via a .NET app just to see if it behaves the same.
I am trying to use a function from SOAP, which will fetch details about a specific news item. The problem is that I don't get the expected results, just a a strange error. I am using the built-in SOAP client in PHP5.
My error is:
Fatal error: Uncaught SoapFault
exception: [Client] SOAP-ERROR:
Encoding: External reference
'https://newsclient.omxgroup.com/cdsPublic/viewDisclosure.action?disclosureId=379485&messageId=454590'
in
/home/********/public_html/********/updatenews3.php:15
My code is:
<?php
$login = '***';
$password = '***';
$client = new SoapClient(
'https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl',
array(
'login' => $login,
'password' => $password
));
$param = array('lastPublicationId' => 361825);
$result = $client->fetchNews($param);
?>
The error is the same for all lastPublicationId, where a result is found. It seems as if PHP is trying to load a link, which is found somewhere in the XML-reply (the URL, which is in the error message), and can't access it. Even though I have googled this a lot, I can't find any solution. The only thing I can find is that this seems to have been reported as a bug in a previous version of PHP, but the error refers to PHP 5.2.2 Since I'm using PHP 5.2.9, I'm thinking it can't be that. I'm suspecting the &-character to be the cause of this error?
The WSDL-file can be found here: https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl
Does somebody know this error, and know of any solution?
It's possible that the XML being returned by $client->fetchNews($param); isn't being escaped properly - there seems to be an unescaped & in the URL which is shown in the error message.
Best thing is probably to check exactly what XML is being returned, by turning on tracing and printing the last response:
$client = new SoapClient(
'https://newsclient.omxgroup.com/wsdl/DisclosureNewsService.wsdl',
array(
'login' => $login,
'password' => $password,
'trace' => 1
));
$param = array('lastPublicationId' => 361825);
try {
$result = $client->fetchNews($param);
}
catch (SoapFault $sf) {
print '<pre>';
// print the exception
print_r($sf);
// print the XML response
print $client->__getLastResponse();
}
A workaround (if the server is returning invalid XML) is to use code similar to the above to catch the exception. You can then manually get at the XML returned (using __getLastResponse()), and clean it up yourself (e.g. using htmlenties or a regexp), before returning it and using it in the rest of your application.