$method ='MerchantFinancialOperationWS';
$configs = array(
'soap_version' => SOAP_1_2,
'cache_wsdl' => WSDL_CACHE_NONE,
'exceptions' => false,
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
'local_cert' => $cert_file,
'passphrase' => $cert_password
);
if($debug) $configs['trace'] = true;
if(substr($url, -5) != '?WSDL') $url.= '?WSDL';
$webService = new SoapClient($url, $configs);
$data = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fin="http://financial.services.merchant.channelmanagermsp.sibs/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://financial.services.merchant.channelmanagermsp.sibs/MerchantFinancialOperationWS/requestFinancialOperationRequest</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>https://enderecodeteste.pt</wsa:Address>
</wsa:ReplyTo>
</soapenv:Header>
<soapenv:Body>
<fin:requestFinancialOperation>
<arg0>
<messageType>N0003</messageType>
<aditionalData>TESTE</aditionalData>
<alias>
<aliasName>351#994999999</aliasName>
<aliasTypeCde>001</aliasTypeCde>
</alias>
<financialOperation>
<amount>400</amount>
<currencyCode>9782</currencyCode>
<operationTypeCode>022</operationTypeCode>
<merchantOprId>11111</merchantOprId>
</financialOperation>
<merchant>
<iPAddress>255.255.255.255</iPAddress>
<posId>880924 </posId>
</merchant>
<messageProperties>
<channel>01</channel>
<apiVersion>1</apiVersion>
<channelTypeCode>VPOS</channelTypeCode>
<networkCode>MULTIB</networkCode>
<serviceType>01</serviceType>
<timestamp>2014-10-31T13:58:49.2934+01:00</timestamp>
</messageProperties>
</arg0>
</fin:requestFinancialOperation>
</soapenv:Body>
</soapenv:Envelope>';
$result = $webService->requestFinancialOperation($data);
I've been trying to implement a soap request with a pem certificate and i'm just getting out of ideas. I know my code should be all wrong but i have no idea what the right direction is. I've been researching but found little no none documentation on this and the team behind the webservice i have to use also wasn't able to help.
I can already communicate with the service using SoapUI so i know the webservice works
Part of the issue is you're sending XML when you may not need to. PHP's built-in SOAP client will handle the XML for you, so you can focus on the objects (the O in SOAP!). You need to construct a data structure (object or array) and pass that to the operation you want to run. First look for the signature of the operation you want using:
$webService = new SoapClient($url, $configs);
var_dump($webService->__getFunctions());
This gives you the API - note that it indicates the data structures it expects in both the input parameters and the output. To see what those data structures look like:
var_dump($webService->__getTypes());
Now you can construct a PHP object with the same fields and structure and pass it in. Your code will look something along these lines:
$webService = new SoapClient($url, $configs);
$parameter = new stdClass();
$parameter->someField = 'N0003';
$parameter->anotherField = 'TESTE';
$result = $webService->requestFinancialOperation($parameter);
Related
$data2=[
"user_name"=>"****",
"password"=>"****",
"customer_num"=>"***",
"process_num"=>000,
];
$wsdl = "https://vbtestservice.vakifbank.com.tr/HesapHareketleri.OnlineEkstre/SOnlineEkstreServis.svc?singleWsdl";
$client =new SoapClient($wsdl,array("trace"=>true,"exceptions"=>0));
$a=$client->__soapCall('GetirDekont', $data2);
echo $client->__getLastResponse();
Result of php : looks like we got no xml document
or response
The requested URL was rejected. Please consult with your administrator."
But
As shown in the pictures the wdsl is working at he SoapUI but how to implement the options in the pure php or in the laravel framework. Thank you you for helping !!
SoapUI return response this xml:
xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">
Peak.Integration.ExternalInbound.Ekstre/ISOnlineEkstreServis/GetirDekontResponse
</a:Action>
</s:Header>
<s:Body>
<GetirDekontResponse xmlns="Peak.Integration.ExternalInbound.Ekstre">
<GetirDekontResult
xmlns:b="http://schemas.datacontract.org/2004/07/Peak.Integration.ExternalInbound.Ekstre.DataTransferObjects"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<b:IslemKodu>VBD0004</b:IslemKodu>
<b:IslemAciklamasi>Talimat için dekont bulunamadı.</b:IslemAciklamasi>
<b:DekontListesi xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
</GetirDekontResult>
</GetirDekontResponse>
</s:Body>
</s:Envelope> ```
I found the solution :)
Quote from Alper Yaman, a member of Laravel Turkey group on Facebook.
To set WSA Addressing and add default wsa:To options on SoapClient connection in Laravel, you can follow these steps:
You can specify "soap_version" and "features" in the options array when creating the SoapClient object. Example:
$options = array(
'soap_version' => SOAP_1_2,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
);
$client = new SoapClient($wsdl, $options);
You can set WSA Addressing and add default wsa:To options by editing the headers of the request sent to the SoapClient object. Example:
$headers = array(
new SoapHeader("http://www.w3.org/2005/08/addressing", "Peak.Integration.ExternalInbound.Ekstre/ISOnlineEkstreServis/GetirDekont", $to),
new SoapHeader("http://www.w3.org/2005/08/addressing", "WEB SERVICE LINK ENDING WITH ?WSDL HERE", $action)
);
$client->__setSoapHeaders($headers);
Note: The $to and $action variables are required values for WSA Addressing.
After doing these operations, try to connect to the web service with the SoapClient object.
If you still get the error, please contact the server's administrator to ensure that the URL is not rejected.
I am using the COLT (ISP) WSDL in PHP (Laravel), I have created all the objects using WSDL2PHPGENERATOR, and imported these into my project.
The XML which works via SOAPUI is the following:
<soapenv:Envelopexmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v5="http://www.colt.net/xml/ns/b2bFramework/v5" xmlns:con="http://aat.colt.com/connectivityservice">
<soapenv:Header/>
<soapenv:Body>
<v5:checkConnectivity>
<checkConnectivityRequest>
<con:checkConnectivityRequest con:schemaVersion="5.0">
<con:requestType>ALL</con:requestType>
<con:requestMode>
<con:requestID>123</con:requestID>
<con:siteAddress>
<con:premisesNumber>16</con:premisesNumber>
<con:streetName>Rue Friant</con:streetName>
<con:cityTown>Paris</con:cityTown>
<con:postalZipCode>75014</con:postalZipCode>
<con:coltOperatingCountry>France</con:coltOperatingCountry>
<con:requiredProduct>Colt Voice Line (v)</con:requiredProduct>
<con:isConvergedVL>false</con:isConvergedVL>
<con:connectivityType>ALL</con:connectivityType>
</con:siteAddress>
</con:requestMode>
</con:checkConnectivityRequest>
</checkConnectivityRequest>
</v5:checkConnectivity>
</soapenv:Body>
</soapenv:Envelope>
My PHP Code is the following:
$request_id = 1123123;
$Connectivity_Type = \App\Classes\WSDLs\COLT\Connectivity_Type::COLTFibre;
$LocationAddress_Type = new \App\Classes\WSDLs\COLT\LocationAddress_Type(array($Connectivity_Type));
$LocationAddress_Type->PremisesNumber = 1;
$LocationAddress_Type->StreetName = "Whittington Avenue";
$LocationAddress_Type->CityTown = "London";
$LocationAddress_Type->PostalZipCode = "EC3V 1PJ";
$LocationAddress_Type->ColtOperatingCountry = \App\Classes\WSDLs\COLT\coltOperatingCountry::UnitedKingdom;
$LocationAddress_Type->RequiredProduct = \App\Classes\WSDLs\COLT\RequiredProduct_Type::ColtIPAccess;
$requestMode = new \App\Classes\WSDLs\COLT\RequestMode_Type($request_id, array($LocationAddress_Type));
$Request_Type = \App\Classes\WSDLs\COLT\Request_Type::SITE;
$schemaVersion = 5.0;
$checkConnectivityRequest = new \App\Classes\WSDLs\COLT\checkConnectivityRequest($Request_Type, $requestMode, $schemaVersion);
$checkConnectivity = new \App\Classes\WSDLs\COLT\checkConnectivity();
$checkConnectivity->setCheckConnectivityRequest($checkConnectivityRequest);
Log::info(array($checkConnectivity));
//return "Check Log";
try{
$a = new \App\Classes\WSDLs\COLT\ColtB2bFrameworkcommonwebSvcProviderb2bFramework_v5(array(
"exceptions" => 0,
"trace" => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'login' => config('mike.COLT_API_USERNAME'),
'password' => config('mike.COLT_API_PASSWORD'),
));
//return var_dump($a->__getTypes());
$response = $a->checkConnectivity($checkConnectivity);
However when getting this working it comes back with the error:
SOAP-ERROR: Encoding: object has no 'checkConnectivityRequest'
property
It won't even show last request etc in order to debug.
I wonder whether it is something do do with the XML having two
Layers.
Have I missed something?
Thanks in advance,
Mike
For anyone who runs across this in future. I updated to a newer version of their WSDL, and it started working, it was clearly an error in that.
However not so much that it didnt work in SOAPUI.
If you encounter this. It may be worth just querying the Data Directly rather than using a soap client in PHP.
I need to send the following SOAP request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://touricoholidays.com/WSDestinations/2008/08/DataContracts">
<soapenv:Header>
<dat:LoginHeader>
<dat:username>myUserName</dat:username>
<dat:password>myPassword</dat:password>
<dat:culture>en_US</dat:culture>
<dat:version>8</dat:version>
</dat:LoginHeader>
</soapenv:Header>
<soapenv:Body>
<dat:GetDestination>
<dat:Destination>
<dat:Continent>Europe</dat:Continent>
<dat:Country>Spain</dat:Country>
<dat:State></dat:State>
<dat:City>Madrid</dat:City>
<dat:Providers>
<dat:ProviderType>Default</dat:ProviderType>
</dat:Providers>
</dat:Destination>
</dat:GetDestination>
</soapenv:Body>
</soapenv:Envelope>
I am trying to achieve this using PHP's built in SoapClient Class. When I run the following code it says "Login failure please check user name and password." But I am very much sure that both the username and password are correct as the same values are being used in other applications.
I think the problem is in the code below. Could you please tell me what is the mistake ?
try{
$client = new SoapClient($soap_url, array("trace" => 1));
$ns = 'http://touricoholidays.com/WSDestinations/2008/08/DataContracts';
$auth = array(
'username' => 'myUserName',
'password' => 'myPassword',
'culture' => 'en_US',
'version' => '8',
);
$header = new SoapHeader($ns, 'LoginHeader', $auth);
$client->__setSoapHeaders($header);
$res = $client->__soapCall("GetDestination", array());
var_dump($res);
}
catch(Exception $e)
{
echo $e->getMessage();
}
you should definitively use a WSDL to php generator that still uses the native SoapClient class such as the PackageGenerator project. It simply generates the PHP SDK according to the WSDL. Then you only have to use the generated classes to construct and send your request. The response is then an object using the generated classes.
I am making a simple web service for communication between two sites I own.
Since it is only a basic application, I've been working without a WSDL file, so in non-WSDL mode as the PHP manual calls it.
This is basically what the client-side looks like:
$client = new SoapClient(null, array('location' => $location, 'uri' => '', 'trace' => TRUE));
$res = $client->__soapCall('myFunc', array($param));
On the server-side, I have a function called myFunc:
$soap = new SoapServer(null, array('uri' => ''));
$soap->addFunction('myFunc');
//Use the request to invoke the service
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$soap->handle();
}
When I actually try invoking the myFunc function, I get and error:
Function 'ns1:myFunc' doesn't exist
For some reason, the soap server is prepending ns1: to the function name!
Using $client->__getLastRequest(), I get:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getTopElement>
<param0 xsi:type="xsd:string">rightcolBox</param0>
</ns1:getTopElement>
</SOAP-ENV:Body>
I'm not a SOAP expert, but it seems to me that the client is causing the error in making the request - or is the server misinterpreting it?
How can I fix this issue?
I had the same problem. When I set SoapClient options' uri to not null, the problem was solved.
$client = new SoapClient(null, array('location' => $location, 'uri' => 'foo', 'trace' => TRUE));
Yes, it can be any string, even "foo" as in this example.
I need to get data from http://ws.jrtwebservices.com/jrtlowfaresearch/jrtlfs.asmx, this service need credential information.such as ID, userid and system value. I put these information into one string:
$xml_post_string = "<POS><Source> <RequestorID Type='21' ID='xxx'/> </Source> <TPA_Extensions> <Provider><System>xxx</System> <Userid>xxx</Userid> </Provider></TPA_Extensions></POS>"
And i also defined SoapClient:
$client = new SoapClient(null, array('uri' => "http://ws.jrtwebservices.com",
'location => "http://ws.jrtwebservices.com/jrtlowfaresearch/jrtlfs.asmx") );
I call soapCall as:
$response = $client->__soapCall('do_LowfareSearch',array($xml_post_string),array('soapaction' => 'http://jrtechnologies.com/do_LowfareSearch'));
Does anybody know why i get empty response?
Thanks very much!
Using your code, the request looks like this:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xm...">
<SOAP-ENV:Body>
<ns1:do_LowfareSearch>
<param0 xsi:type="xsd:string">
"<POS><Source> <RequestorID Type='21' ID='xxx'/> </Source> <TPA_Extensions> <Provider <System>xxx</System> <Userid>xxx</Userid> </Provider></TPA_Extensions></POS>"
</param0>
</ns1:do_LowfareSearch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The client used the method you passed but could not structure the parameters the way you gave them. All of your parameters are just in " " inside of <param0>.
(Also, you are missing a ' after location. 'location => "http:...)
When you make your SOAP client you want to set the WSDL, it will do all the XML formatting for you.
The WSDL should have the location in it so you do not need to worry about that.
I like to use a WSDL validator to test out the methods and see their parameters.
You should structure the information you want to pass as arrays or a classes and let the SOAP client and WSDL convert it into the XML you need.
So something like this is what you are looking for:
<?php
//SOAP Client
$wsdl = "http://ws.jrtwebservices.com/jrtlowfaresearch/jrtlfs.asmx?WSDL";
$client = new SoapClient($wsdl, array( 'soap_version' => SOAP_1_1,
'trace' => true, //to debug
));
try {
$args = array(
'companyname'=> 'xxx',
'name'=> 'xxx',
'system'=> 'xxx',
'userid'=> 'xxx',
'password'=> 'xxx',
'conversationid'=>'xxx',
'entry'=> 'xxx',
);
$result = $client->__soapCall('do_LowfareSearch', $args);
return $result;
} catch (SoapFault $e) {
echo "Error: {$e}";
}
//to debug the xml sent to the service
echo($client->__getLastRequest());
//to view the xml sent back
echo($client->__getLastResponse());
?>