Related to this question: How to request an answer from a SOAP XML API?
I have this PHP script sending the request with the required fields:
$client = new SoapClient('https://live.domainbox.net/?WSDL');
$params = array(
'AuthenticationParameters' => array(
'Reseller' => 'resellername',
'Username' => 'myusername',
'Password' => 'mypassword'
),
'CommandParameters' => array(
'DomainName' => 'mydomain.com',
'LaunchPhase' => 'GA'
)
);
$result = $client->CheckDomainAvailability($params);
print_r($result);
I get the following error message:
Fatal error: Uncaught SoapFault exception: [soap:VersionMismatch]
Possible SOAP version mismatch: Envelope namespace
http://schemas.xmlsoap.org/soap/envelope/ was unexpected.
Expecting http://www.w3.org/2003/05/soap-envelope. in
/home/nosa/public_html/dev/check-domain-availability.php:20 Stack
trace: #0
/home/nosa/public_html/dev/check-domain-availability.php(20):
SoapClient->__call('CheckDomainAvai...', Array) #1
/home/nosa/public_html/dev/check-domain-availability.php(20):
SoapClient->CheckDomainAvailability(Array) #2 {main} thrown in
/home/nosa/public_html/dev/check-domain-availability.php on line 20
I removed and recompiled apache to include the latest SOAP version available using WHM/cPanel.
My question is:
How do I send the correct envelope namespace?
When building your soap_client object, you can pass an option's array, by default, the version will be 1.1 as per php documentation.
The error you have seems to point out that the service might be SOAP 1.2 so you need to set it to 1.2...
$client = new SoapClient('https://live.domainbox.net/?WSDL', array('soap_version' => SOAP_1_2));
Try that out!
Related
When sending a request from my PHP soapclient as described below, I get:
[getInterestAndExchangeRates failed: Please check inparameters in Xxx].
I suspect that it is the [$response] line that has wrong syntax. More specific the [$searchRequestParameters]. I have checked that all the content in the array is in the correct order.
Question:
Is there something wrong with below code syntax?
I have followed following instructions:
https://swea.riksbank.se/sweaWS/docs/api/call/getInterestAndExchangeRates.htm
<?php
/**
* A soapclient request to Swedish Central bank, API.
*/
$client = new SoapClient("https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdl");
$searchGroupSeries = array(
"groupid" => 2,
"seriesid" => "SECBREPOEFF"
);
$searchRequestParameters = array (
"aggregateMethod" => "W",
"avg" => true,
"datefrom" => "2018-01-01",
"dateto" => "2019-01-01",
"languageid" => "en",
"max" => true,
"min" => false,
"searchGroupSeries" => $searchGroupSeries,
"ultimo" => false
);
// Test 1 (pointing out above array, does not work):
$response = $client->__soapCall("getInterestAndExchangeRates", $searchRequestParameters);
// Test 2 (wrap in above array inside another array, does not work):
// $response = $client->__soapCall('getInterestAndExchangeRates', array('searchRequestParameters' => $searchRequestParameters));
var_dump($response);
Error:
PHP Fatal error: Uncaught SoapFault exception: [soap:Server] getInterestAndExchangeRates failed: Please check inparameters in [path]_(does_not_work).php:22
Stack trace:
#0 [path]_(does_not_work).php(22): SoapClient->__soapCall('getInterestAndE...', Array)
#1 {main}
thrown in [path]_(does_not_work).php on line 22
I am trying to integrate fedex API and getting this error .
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "../wsdl/RateService_v13.wsdl" in test.php on line 12
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '../wsdl/RateService_v13.wsdl' in D:\wamp\www\fedexapi\AddressValidationService_v4_php\php\AddressValidationWebServiceClient\rate_test.php:12 Stack trace: #0 D:\wamp\www\fedexapi\AddressValidationService_v4_php\php\AddressValidationWebServiceClient\rate_test.php(12): SoapClient->SoapClient('../wsdl/RateSer...', Array) #1 {main} thrown in test.php on line 12
<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 2.0.0
require_once('../library/fedex-common.php5');
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../wsdl/LocationsService_v3.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
?>
How to solve this ?
Afaik the SoapClient first aprameter need to be an URI, not a local filename on your disk.
The error indicated that it was unable to load the wsdl.
Have a look at the specs and this expample should make it clear.
Relative path works as well.
In my case, I had to fix the wsdl file's relative path.
I can parse the .WSDL file and call the functions using soapUI, but not
using PHP5. It has also been shown to work with JAVA/AXIS and .NET.
I need the WSDL caching functionality of the PHP5 SOAP procedures
otherwise I might stick with soapUI.
Reproduce code:
$optional = array
(
'trace' => 1,
'exceptions' => true,
'soap_version' => SOAP_1_1,
'encoding' => 'ISO-8859-1'
);
$wsdl = 'https://www-a.audanet.de/b2b/services/AXAttachmentService?wsdl';
$client = new SoapClientAuth($wsdl, $optional);
Expected result:
A useable instance of a SoapClient object.
Actual result:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: unexpected 'attribute' in complexType in ../class/SoapClientAuth.php:62
Stack trace:
0 ../class/SoapClientAuth.php(62): SoapClient->SoapClient('https://www-a.a...', Array)
1 ../class/Ws.php(30): SoapClientAuth->SoapClientAuth('https://www-a.a...', Array)
2 ../zalacz.php(468): Ws->podlaczenieWS()
3 {main}
thrown in ../class/SoapClientAuth.php on line 62
I am trying to connect osticket support system with opencart.
I tried to integrate with this SOAP
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$osticket = new SoapClient('http://www.website.com/osticket/api/soap/index.php?wsdl');
// Set up the parameters
$args = array(
'username' => 'WebService',
'password' => 'MySecr3tp#ssword',
'origin' => 'Web',
'alertUser' => true,
'alertStaff' => true,
'ticketData' => array(
'name' => utf8_encode('sir Test'),
'email' => utf8_encode('some#email.com'),
'subject' => utf8_encode('testing'),
'message' => utf8_encode('this is a message'),
'topicId' => 3, //topic Website Support
'deptId' => 2, //department Sales
'staffId' => null,
'duedate' => null,
'time' => null,
'pri' => 2, // default priority
'phone' => null,
)
);
try {
// Send the request and receive the ticketID
$result = $osticket->__call('ostTicket.open',$args);
}
catch (SoapFault $e) {
throw $e;
}
?>
The error I get is
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'source' property in /home/website/website.com/catalog/view/theme/testtheme/template/information/contact.tpl:60
Stack trace:
#0 /home/website/website.com/catalog/view/theme/testtheme/template/information/contact.tpl(60): SoapClient->__call('ostTicket.open', Array)
#1 /home/website/website.com/vqmod/vqcache/vq2-system_engine_controller.php(67): require('/home/website/tu...')
#2 /home/website/website.com/catalog/controller/information/contact.php(127): Controller->render()
#3 /home/website/website.com/vqmod/vqcache/vq2-system_engine_front.php(43): ControllerInformationContact->index()
#4 /home/website/website.com/vqmod/vqcache/vq2-system_engine_front.php(29): Front->execute(Array, Array)
#5 /home/website/website.com/index.php(238): Front->dispatch(Object(Action))
#6 {main} thrown in/home/website/website.com/catalog/view/theme/testtheme/template/information/contact.tpl on line 60
Here is the line 60 (/template/information/contact.tpl):
$result = $osticket->__call('ostTicket.open',$args);
I'd be grateful if anyone kindly help me in this issue.
SOAP Info
This is from phpinfo
Soap Client enabled
Soap Server enabled
Directive Local Value Master Value
soap.wsdl_cache 1 1
soap.wsdl_cache_dir /tmp /tmp
soap.wsdl_cache_enabled 1 1
soap.wsdl_cache_limit 5 5
soap.wsdl_cache_ttl 86400 86400
I'm also having same problem, and I've been searching the web and found no answer. So, I traced it myself. And I loved to share how I fixed it.
As you can see on the http://www.website.com/osticket/api/soap/index.php?wsdl (change it to your URL)
under the ( xsd:complexType name="TicketData" ),which parameters needed for ostTicket.open
you can see that there's an element (xsd:element name="source" type="xsd:string") named source, so that's what is missing on the ticketData array. Just add that inside your ticketData array, can be assigned w/ null.
ex. 'source' => null,
This solved my problem. Hope it helps.
i am trying to calling .net webservice in php
below is my code.
<?php
$client = new SoapClient("http://test.etech.net/PanelIntegration/PanelIntegration.asmx?wsdl");
<?php
$sh_param = array(
'Username' => 'IntegratorLPI',
'Password' => 'password531');
$headers = new SoapHeader('http://wms.etech.net/', 'UserCredentials', $sh_param);
$client->__setSoapHeaders($headers);
$params = array('CustomerName' => 'Mr Smith','ContactMobileNo' => '01237 376347',
'AddressLine1' => '33 Amblecote Road',
'AddressTown' => 'Cambridgeshire',
'AddressPostCode' => 'NW23 6TR',
'VendorAddressLine1' => '80 Norton Road',
'VendorAddressTown' => 'Hickley ',
'VendorAddressCounty' => 'Cambridgeshire',
'VendorAddressPostCode' => 'NW23 2AQ',
'RegionalOfficeID' => '3',
'ExternalNotes' => 'Case Accepted',
'UPRN' => '',
'InstructionTypeID' => '2',
'PropertyTypeID' => '11',
'PropertyTenure' => '2',
'SurveyorID' => '23',
'RRN' => '0240-9002-0391-3520-0020',
'NewInstruction'=> 'true',
'StatusID' => '1'
);
$result = $client->__soapCall("UpdateInstruction", $params );
print_r( $result);
?>
i have got this error
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\xampp\htdocs\test2.php:33 Stack trace: #0 C:\xampp\htdocs\test2.php(33): SoapClient->__soapCall('UpdateInstructi...', Array) #1 {main} thrown in C:\xampp\htdocs\test2.php on line 33
You probably need to send something like:
$result = $client->__soapCall("UpdateInstruction", array('Instruction' => $params );
Where Instruction is the name of the object that you are passing.
It looks like a NullReferenceException was thrown on the server side. So, it's a matter of the parameters to whatever function is occurring on the server side generating that error.
Regardless of why, per best practices, this is an error in the .NET service. The NullReferenceException should really be replaced with something more specific.
Can you get in touch with whomever wrote the service to get more information to troubleshoot? It's quite possible that you have a parameter misnamed in your $params array, but you're probably going to need some help from the service writer.