I have written web service in PHP. It has been working fine for couple of weeks. Today I had to change my SOAP client to be in non WSDL form, after making the following change, I am getting this annoying error:
Procedure 'FUNCTIONNAME' not present
My code:
//$client = new SoapClient("STWebServiceWSDL.wsdl", array('trace' => 1));
//This is working, but why, non wsdl below not working
$client = new SoapClient(null, array('location' => "https://mysite.com/STserver.php",
'uri' => "https://mysite.com/STserver.php",
'trace'=>1));
Please help, I could not find any solution on the Net for the whole day.
My SOAP server is like this:
$server = new SoapServer("STWebServiceWSDL.wsdl");
Related
I need to setup a php soapserver that only accepts traffic from a specific (validated) certificate. I've searched everywhere, but have not found a way to do that.
I currently use
$server = new SoapServer($this->wsdl);
It would be amazing if something like this would work:
$server = new SoapServer($this->wsdl, array('local_cert' => $this->cert_file, 'passphrase' => $this->passphrase));
Any help is greatly appreciated.
I am facing weired issue for soap api on my development and production server.
We have itegrated bunch of 3rd party soap API which are fetching details from 3rd party and displaying data on our site.It is working very well.Most of time APIs working perfectly.It happen in some random period of time soap api response becomes null and we get 0 in api response.We had discuss with 3rd party service about that issue and they had replied after check their log that, they are providing each and every response raising from our end.Can any one guide me does it code base issue or server base issue? and how to get rid of it as it is loosing client's business because of it.
Below are functinal of our WSDL calling from PHP soap function.
We send request for validation to 3rd party api, and store temp. security key on our server. And use this security key as token for each api.while this random glitch happen we does not get any response in that case. below is my soap code for call wsdl api.
$wsdl = 'URL';
$options = array(
'cache_wsdl' => 0,
'trace' => 1,
'stream_context' => stream_context_create(array(
'ssl' => array(
'verify_peer' => 0,
'verify_peer_name' => 0,
'allow_self_signed' => 1
)
)));
$soapCall = new SoapClient($wsdl,$options);
try {
$response = $soapCall->__soapCall("API_FUNCTION", array($params));
//Save records to log
$requestParamLogs = $soapCall->__getLastRequest();
$responseParamLogs = $soapCall->__getLastResponse();
}
catch (SoapFault $e) {
$requestParamLogs = $soapCall->__getLastRequest();
$responseParamLogs = $soapCall->__getLastResponse();
}
While we are facing such random issue on our deployment and production server, we do not get such issue in local server.
Note: We are getting response of each API in postman without issue all time.
I have tried google for it, but do not get anything suitable solution for my case so anyone having an idea, please guide me.
I have been using an API for a WMS which has updated to include authentication headers. I have been provided some required details but have been unable to sucessfully use the API. I have asked the developers but they are unable to help as they do not use PHP.
Previous to the last update, this would work:
$wsdl = URL_HERE;
$soapClient = new SoapClient($wsdl);
$params = array('customer' => $get_users_company->custcode_code);
$response = $soapClient->GetProducts($params);
With the authentification headers, this is what I currently have which is causing the error Authentication header missing
$wsdl = URL_HERE;
$ns = NAMESPACE_HERE;
$soapClient = new SoapClient($wsdl);
$headerbody = array('ID' => 'PROVIDED_ID_HERE', 'KEY' => 'PROVIDED_KEY_HERE');
$headers = new SOAPHeader($ns, 'AuthHeader', $headerbody);
$soapClient->__setSoapHeaders($headers);
$response = $soapClient->__soapCall("GetProducts", array('customer' => $get_users_company->custcode_code));
I'm not 100% sure I am doing this correctly, but without the last line, I get no errors and the page loads fine (No results). Am I correct in thinking the headers are being sent?
I have heard the good old, "we can't help because we are XML Gods and your little php is beneath us"...but you can still get technical support from them by speaking their XML language. Dump out your actual, raw XML and communicate with them using that - don't mention PHP.
Follow the example here and get your request. Make sure it is matching what the documentation of your API is requesting. If it is, call your technical support and show them your XML. If it isn't, then, you know what you need to fix.
When using $soapClient->__soapCall() the second parameter takes an array, and your data structure is also an array, so you maybe should be doing:
$params = array('customer' => $get_users_company->custcode_code);
$response = $soapClient->__soapCall("GetProducts", array($params));
Or just leave it as:
$response = $soapClient->GetProducts($params);
Which looks nicer.
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 have been asked by a friend for some help with his boss' website. I have literally no knowledge of SOAP and was wondering if someone can point me in the right direction. I have looked for tutorials but I am really stuck.
I have been given an XML file and need to PUT this information to a SOAP service using WSDL. I have been given a username and password for this so my PHP script will need to use authentication of some kind right?
I have tried already to connect to the WSDL given to me but I keep getting this error.
Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://compassqa.cengage.com:4502/cdes/services/cdes_ws?wsdl' : Extra content at the end of the document in /home/birdnetw/public_html/zesty-designs.co.uk/misc/soap-test/put.php on line 10
My code looks like this at the moment. I have more but it's a complete mess so commented it out for now.
$wdsl = "https://compassqa.cengage.com:4502/cdes/services/cdes_ws?wsdl";
$client = new SoapClient($wdsl, array(
"login" => "****",
"password" => "***",
"trace" => 1,
"exceptions" => 0));
I'm not asking for someone to hold my hand but if you could just point me in the right direction that would be grand.