How can I get the data from WSDL file using SOAP1.2 - php

I am working for a project and I have to get data from a WSDL url
http://80.127.98.91:6060/BonnenExterneApp?wsdl
Our webservice uses SOAP1.2 and I am using Nusoap0.9.5 library to get the data. But I am getting an error like
RESULT = Array
(
[faultcode] => e:VersionMismatch
[faultstring] => received something that is not a SOAP Envelope
)
Constructor error
e:VersionMismatch: received something that is not a SOAP Envelope
The Code I am using to call web service is
<?php
require_once('lib/nusoap.php');
//Declare some paramaters for our soapclient. Need to make sure its set to soap 1.2
$params = array("soap_version"=> SOAP_1_2,
"trace"=>1,
"exceptions"=>0,
);
$iboks = new nusoap_client('http://80.127.98.91:6060/BonnenExterneApp?wsdl', $params);
$result = $iboks->call('AW_SYS01_01_Login', array("piUserId" => "myusername", "piPassword" => "mypassword"));
echo "<pre>RESULT = ".print_r($result, true)."</pre>";
$err = $iboks->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
exit();
}
?>
Tell me what I am doing wrong, I have tested this url from a online tools. Online tools are giving the answers but I want to get the data from PHP.
Tool which I am using is
http://soapclient.com/soaptest.html
For security reason the username and passwords are changed here.
Thanks in advance.

I got an answer for my problem.
URL is just for example but my exact url is also working now.
I was using the nusoap for wsdl1.2 but the nusoap is not providing the support for the wsdl1.2 so I choosed the PHP Soap Client.
http://php.net/manual/en/class.soapclient.php
And My code is now looking as
<?php
$client = new SoapClient("http://www.webservicex.com/globalweather.asmx?wsdl", array('soap_version' => SOAP_1_2));
$something = $client->GetCitiesByCountry(array("CountryName"=>"India"));
echo "<pre>"; print_r($something);
die();
?>
And the output is like
stdClass Object
(
[GetCitiesByCountryResult] =>
British Indian Ocean TerritoryDiego Garcia
IndiaAhmadabad
IndiaAkola
IndiaAurangabad Chikalthan Aerodrome
IndiaBombay / Santacruz
IndiaBilaspur
IndiaBhuj-Rudramata
IndiaBelgaum / Sambra
IndiaBhopal / Bairagarh
IndiaBhaunagar
IndiaGoa / Dabolim Airport
IndiaIndore
IndiaJabalpur
IndiaKhandwa
IndiaKolhapur
IndiaNagpur Sonegaon
IndiaRajkot
IndiaSholapur
IndiaAgartala
IndiaSiliguri
IndiaBhubaneswar
IndiaCalcutta / Dum Dum
IndiaCar Nicobar
IndiaGorakhpur
IndiaGauhati
IndiaGaya
IndiaImphal Tulihal
IndiaJharsuguda
IndiaJamshedpur
IndiaNorth Lakhimpur
IndiaDibrugarh / Mohanbari
IndiaPort Blair
IndiaPatna
IndiaM. O. Ranchi
IndiaAgra
IndiaAllahabad / Bamhrauli
IndiaAmritsar
IndiaVaranasi / Babatpur
IndiaBareilly
IndiaKanpur / Chakeri
IndiaNew Delhi / Safdarjung
IndiaNew Delhi / Palam
IndiaGwalior
IndiaHissar
IndiaJhansi
IndiaJodhpur
IndiaJaipur / Sanganer
IndiaKota Aerodrome
IndiaLucknow / Amausi
IndiaSatna
IndiaUdaipur Dabok
IndiaBellary
IndiaVijayawada / Gannavaram
IndiaCoimbatore / Peelamedu
IndiaCochin / Willingdon
IndiaCuddapah
IndiaHyderabad Airport
IndiaMadurai
IndiaMangalore / Bajpe
IndiaMadras / Minambakkam
IndiaTiruchchirapalli
IndiaThiruvananthapuram
IndiaVellore
)
I was willing to get the same as answer.
Thanks a lot and someone may get help from this post.

Related

Plivo PHP API 4.0, can't get callstatus or duration (action URL does not execute?)

I hope you can help me with an issue with phone call dialings using Plivo PHP (new SDK 4.0). First I will indicate what I want to achieve:
- A client on my website wants to talk with an agent of main, so he introduces his telephone number in a form, choose an agent, and finally when submit, the website connect both of them dialing (this works). But then, (here begin my problems), I can't retrieve the call details (status, duration, initial and end dates of the call, etc...) for invoicing the client according to some of these details.
Edited 2018/02/23:
Ramya, the 600 error has dissapeared and everything seems to be ok as I see in the Plivo debug log. Below are my new codes (I think better done thanks to your instructions), and then, I show you the Plivo debud log (perhaps it's better you can see it inside my account, call made Feb 23, 2018 18:33:15), and finally I see my server debug error log is empty!.
The main problem is that dialstatus.php file, although seems to receive the parameters, I don't know how to access them because dialstatus.php does not execute showing the data in my monitor (in my code for example, this line never shows in the monitor screen:)
echo "Status = $estado, Aleg UUID = $aleg, Bleg UUID = $bleg";
So even though it receives the parameters, I can not access them to manipulate them, print them on the screen, do ifs with them, etc. May it be perhaps a permission problem with the files? (These php files have 6,4,4 permissions on my server, the same as the others).
Thank you!
Code 1: makecall.php
require 'vendor/autoload.php';
use Plivo\RestClient;
$client = new RestClient("**********", "**************************");
$telefono_cliente = "34*******";
$telefono_experto = "34*********";
$duracion = 50;
try {
$response = $client->calls->create(
"3491111111",
[$telefono_experto],
"https://www.ejemplo.com/llamar/response.php?telf=$telefono_cliente",
'POST',
[
'time_limit' => $duracion,
]
);
$id = $response->requestUuid;
echo "<br>Este es el requestUuid: " . $id . "<br><br>";
}
catch (PlivoRestException $ex) {
print_r($ex);
}
?>
Code 2: response.php
require 'vendor/autoload.php';
use Plivo\XML\Response;
$resp = new Response();
$params = array(
'callerId' => '3491111111',
'action' => "https://www.ejemplo.com/llamar/dialstatus.php",
'method' => "POST",
'redirect' => "false"
);
$body3 = 'Desde ejemplo un cliente desea hablar con usted.';
$params3 = array(
'language' => "es-ES", # Language used to read out the text.
'voice' => "WOMAN" # The tone to be used for reading out the text.
);
$resp->addSpeak($body3,$params3);
$dial = $resp->addDial($params);
//$number = "34**********";
$number = $_GET['telf'];
$dial->addNumber($number);
Header('Content-type: text/xml');
echo($resp->toXML());
/*
Output:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Speak language="es-ES" voice="WOMAN">Desde ejemplo un cliente desea hablar con usted.</Speak>
<Dial redirect="false" method="POST" action="http://www.ejemplo.com/llamar/dialstatus.php" callerId="3491111111">
<Number>34********</Number>
</Dial>
</Response>
*/
?>
Code 3: dialstatus.php
// Print the Dial Details
$estado = $_REQUEST['DialStatus'];
$aleg = $_REQUEST['DialALegUUID'];
$bleg = $_REQUEST['DialBLegUUID'];
echo "Status = $estado, Aleg UUID = $aleg, Bleg UUID = $bleg";
?>
Plivo Sales Engineer here.
Redirect = true is used only when you want to continue the call by returning another XML in your action URL. For you use case, you don't have to use this parameter. Even if the Redirect is set to false, Plivo will make a request to the action URL with a list of parameters. I looked into your account (here) and I can see this request getting sent with DialStatus, ALegUUID, BLegUUID along with other parameters.
Dial Action URL is the best place to know the DialStatus and DialHangupCause.
You can find the call duration and billing amount in Hangup URL request as well. This Hangup URL can be configured in your first API call (to the expert). By default, hangup URL is set to Answer URL.
Please raise a support ticket with us for further assistance.

How to integrate xml hotel booking api using php

I am working for a project and I have to get data from a WSDL. This is my webservice url: http://203.109.97.241/axis/services/searchhoteldetails?wsdl. I've tried to integrate hotel booking xml api using php. I can get hotel result from with this code.
$xml_request = "<HotelSearchRequest>
<clientinfo>
<companycode>companycode</companycode>
<username>username</username>
<password>password</password> </clientinfo>
<hotelinfo>
<country>India</country>
<city>Goa</city>
<checkindate>20/04/2014</checkindate>
<checkoutdate>21/04/2014</checkoutdate>
<hotelname>thaj</hotelname>
<norooms>2</norooms>
<starrating/>
<roomtype/>
<responsetype>C</responsetype>
<roominginfo> </hotelinfo> </HotelSearchRequest>";
$client = new SoapClient("http://203.109.97.241/axis/services/searchhoteldetails?wsdl", array('soap_version' => SOAP_1_2));
$something = $client->getHotelDetailsXML($xml_request);
//var_dump($client->__getFunctions());
//var_dump($client->__getTypes());
var_dump($something);
print_r('<pre>');
print_r($something);
print_r('</pre>');
die();
?>
this is my output:1764 SRHOT7416 India Amla 30/08/2016 3 02/09/2016 2 0 HTRI143851 WebService Demo Webservice Hotel Group, has established four properties conveniently located in the commercial capital of India, Mumbai, since 1984.
These are fine. But my problem is how to echo only the country name from this result.
I'm not really sure what do you want to do... If you want to echo country name from the xml, you may want to use built-in SimpleXML parser.
I haven't used it, but this may be the solution.
Hope it works.

PHP - Access twitter api response variables

I'm using the twitter api to get my latest mentions.
Twitter api link: https://dev.twitter.com/rest/reference/get/statuses/mentions_timeline
Function used to get last mentions:
function twitter_get_tweets(){
$connection = $this->twitter_auth();
$latest_tweet = $connection->get('statuses/mentions_timeline', array('count' => 1));
return $latest_tweet;
}
Preview of response: http://projects.helpful.ninja/twitter/
Sadly im not able to access the variables in there directly, such as the text node.
Example:
[text] => #pr0b_ Submit a request to our Support team and they'll be in touch ASAP
Been testing something like:
$twitter_bot = new twitter_bot_functions($twitter_settings['api_key'], $twitter_settings['api_secret'], $twitter_settings['access_token'], $twitter_settings['access_token_secret']);
$get_latest_mention = $twitter_bot->twitter_get_tweets();
echo $get_latest_mention['text'];
Does someone have a idea what I'm doing wrong?
It is an array first and then a stdClass object. So you should use it like
echo $get_latest_mention[0]->text;

SOAP-ERROR: When using Enterprise Client for SalesForce

I am attempting to pass a custom field via a SOAP Client to SalesForce, here's my existing code:
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
$leadConvert = new stdClass;
$leadConvert->leadId = $eLEADID;
$leadConvert->Custome_field = true;
$leadConvertArray = array($leadConvert);
echo "<pre>";
print_r($leadConvertArray);
echo "</pre>";
$leadConvertResponse = $mySforceConnection->convertLead($leadConvertArray);
echo "<pre>";
print_r($leadConvertResponse);
echo "</pre>";
}
catch (Exception $e) {
echo $e->faultstring;
}
The way it's being passed to SOAP is this:
Array
(
[0] => stdClass Object
(
[leadId] => XXXXXXXXXX
[Custom_field] => 1
)
)
And my error that I am getting is as follows:
SOAP-ERROR: Encoding: object has no 'convertedStatus' property
Do I have to set something in the WSDL in order for this to work? This is to attempt to update a leadID in SalesForce to have it be converted to account/opportunity.
Is there a better way for me to debug this and see what I am missing maybe from the WSDL?
Note: the error means that you "literally" don't have the parameter set in the request. To fix it, simply pass what it's complaining about.
New Issue:
After adding the request, I am getting the following error:
Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location
Not quite sure what that error means at all. Any thoughts?
For the error:
Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location
It appears you are trying to set a custom field on the Lead record to a boolean value.
Custom fields in Salesforce will typically end with the __c suffix.
Check the API name for the field in Salesforce and ensure the user who generated and is accessing the Enterprise API has field level access to it.
Then you code should be something like:
$leadConvert->Custom_field__c = true;
It also seems a bit odd that you are setting a custom field for a Lead and then passing it to the convertLead() web method. See the LeadConvert Arguments, which include convertedStatus.

Updating XML with PHP and returning to .NET Web Service dataset with SOAP

I am using PHP5 and Codeigniter to connect to a .NET web service through SOAP requests. I'm having trouble making an update to that dataset. This is my first experience working with Codeigniter (although doesn't factor here much), SOAP, PHP SimpleXML class, and .NET web services in general. For example, this is to update a user profile. I don't have any problems getting responses but I'm unsure how to update this based on the user's edits to the profile.
My string from the dumping request is this (Note: I'm concerned with the 0, which is the start of the dataset. The 1111 is username and the next 1111 is a password)
11111111 0RandyFloydGM1955-11-05T00:00:00-04:00317787129131789770001910 E. Markwood AvenueIndianapolisIN46227falsefalse
This gives me a 400 Bad Request error. It seems obvious that is due to the space between the 0 and the last 1. By doing htmlspecialchars() I see that it looks like it is the xml declaration isn't needed.
<?xml version="1.0"?> <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml- msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><dsEmployee xmlns="http://SHSSrv/dsEmployee.xsd"><Employee diffgr:id="Employee1" msdata:rowOrder="0"><EmplId>0</EmplId><FirstName>Randy</FirstName><LastName>Floyd</LastName><MI>G</MI><Sex>M</Sex><DOB>1955-11-05T00:00:00-04:00</DOB><HomePhoneArea>317</HomePhoneArea><HomePhone>7871291</HomePhone><WorkPhoneArea>317</WorkPhoneArea><WorkPhone>8977000</WorkPhone><Address1>1920 E. Markwood Avenue</Address1><Address2/><City>Indianapolis</City><St>IN</St><ZIP>46227</ZIP><ReceiveNewsLetter>false</ReceiveNewsLetter><PagerArea/><PagerNo/><EmailAddress>randy#test.com</EmailAddress><SpanishContact>false</SpanishContact></Employee></dsEmployee></diffgr:diffgram>
Taking the original response and just sending it back as update works like this.
111111110RandyFloydGM1955-11-05T00:00:00-04:00317787129131789770001910 E. Markwood AvenueIndianapolisIN46227falsefalse
And with htmlspecialchars() looks like this (No XML declaration):
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml- msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><dsEmployee xmlns="http://SHSSrv/dsEmployee.xsd"><Employee diffgr:id="Employee1" msdata:rowOrder="0"><EmplId>0</EmplId><FirstName>Randy</FirstName><LastName>Floyd</LastName><MI>G</MI><Sex>M</Sex><DOB>1955-11-05T00:00:00-04:00</DOB><HomePhoneArea>317</HomePhoneArea><HomePhone>7871291</HomePhone><WorkPhoneArea>317</WorkPhoneArea><WorkPhone>8977000</WorkPhone><Address1>1920 E. Markwood Avenue</Address1><Address2/><City>Indianapolis</City><St>IN</St><ZIP>46227</ZIP><ReceiveNewsLetter>false</ReceiveNewsLetter><PagerArea/><PagerNo/><EmailAddress>randy#test.com</EmailAddress><SpanishContact>false</SpanishContact></Employee></dsEmployee></diffgr:diffgram>
Here is the code:
function employee_update_request()
{
ini_set( 'soap.wsdl_cache_ttl' , 0 );
//Get XML from the Employee Profile Request
$response = $this->employee_profile_request();
//Turn the string into an object to manipulate
$dataset = simplexml_load_string($response->any);
//Manipulate some data from the update form
$dataset->dsEmployee->Employee->EmailAddress = "randy#test.com";
$dataset->dsEmployee->Employee->Address1 = "1920 E. Markwood Avenue";
$any = $dataset->saveXML();
//Add back the string to the original response object returned from web service
$response->any = $any;
//Get username and password for the params
$username = $this->session->userdata('username');
$password = $this->session->userdata('password');
$params = array('sUserId' => $username, 'sPassword' => $password, 'dsEmployee' => $response);
//SOAP Options
$options = array(
'soap_version'=>SOAP_1_1,
'exceptions'=> 0,
'trace'=> 1,
'uri' => "http://www.w3.org/2003/05/soap-envelope"
);
//New soap client with options
$client = new SoapClient('http://localhost/SHSSRV/SHSSrv.asmx?WSDL', $options);
//Request the employee profile fromt the webservice, passing in credentials
$update_request = $client->EmployeeUpdateRequest($params);
$update_response = $update_request->EmployeeUpdateRequestResult;
return $update_response;
}
I really need help, I need to figure out how best to make updates to this data. Am I able to get the declaration stripped out somehow, or should I request that the .NET web service be changed in some way? I don't have access directly to that but I can talk to the developer if there is a better way all together.
Thanks!
I've solved this by doing this. I'd love to know if there is a better way though.
$no_xml_doctype = str_replace('<?xml version="1.0"?>' , '' , $any);
$trimmed = trim($no_xml_doctype);
$response->any = $trimmed;
//Get username and password for the params
$username = rtrim($this->session->userdata('username'));
$password = rtrim($this->session->userdata('password'));
$params = array('sUserId' => $username, 'sPassword' => $password, 'dsEmployee' => $response);

Categories