Send empty string with SoapClient - soap

I am integrating a website with a SOAP API.
But I am facing an issue when I need to send an empty string (not a null value) as I do with SoapUI:
<soapenv:Body>
<urn:Datos_Articulo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<ID xsi:type="xsd:string"></ID>
<IP xsi:type="xsd:string">0</IP>
<CodS xsi:type="xsd:string">TA8094BK</CodS>
<Nombre_Carrito xsi:type="xsd:string">?</Nombre_Carrito>
<TablaSinTags xsi:type="xsd:boolean">?</TablaSinTags>
</urn:Datos_Articulo>
</soapenv:Body>
But when doing this and inspecting the request with $client->__getLastRequest() method, it always sends this:
<SOAP-ENV:Body>
<ns1:Datos_Articulo>
<ID xsi:type="xsd:string">Array</ID>
<IP xsi:nil="true"/>
<CodS xsi:nil="true"/>
<Nombre_Carrito xsi:nil="true"/>
<TablaSinTags xsi:nil="true"/>
</ns1:Datos_Articulo>
</SOAP-ENV:Body>
This is how My parameters are prepared before sending them:
$params = array(
"ID" => "",
"CodS" => $code,
"IP" => '0',
'TablaSinTags' => false
);

Solved.
The error was when calling the __soapCall method, I was passing as argument:
array($params) instead of only $params (since $params is already an array).
I double checked the arguments needed at: https://www.php.net/manual/es/soapclient.soapcall.php

Related

Sending Very Specific SOAP::Lite requests

My company uses has a lot of internal APIs that use very specific header and formatting requirements. I am new to SOAP::Lite and I'm trying to make it work within the company's framework.
Try #1:
Ideally, I would like to be able to just take the raw XML template (see bottom of the post), populate some placeholder variables, and send it to the endpoint using the following code:
my $client = SOAP::Lite->new( proxy => "$serviceURL");
my $reply = $client->InquireEnterpriseOrderDataRequest($rawxml);
However, this results in my header and request sections being enclosed in it's own "envelope", "body" and "InquireEnterpriseOrderDataRequest" which is rejected by the service.
Try #2:
The next thing I tried was to break my request into two pieces: header and request and use SOAP::Data and SOAP::Header to send those:
my $rawxmlheader = '<ns2:MessageHeader xmlns:ns2="http://mycompany.com/MessageHeader.xsd" xmlns="http://mycompany.com/CingularDataModel.xsd">
<ns2:TrackingMessageHeader>
<version>111</version>
<originalVersion/>
<messageId/>
<originatorId>ABC</originatorId>
<responseTo/>
<returnURL/>
<timeToLive>360000</timeToLive>
<conversationId>9AF0E9281A524262980F5284F4C57888_CCE423E277C74FA9A84D2155CD612EB3_0</conversationId>
<routingRegionOverride/>
<dateTimeStamp>2017-05-12T12:47:53Z</dateTimeStamp>
<uniqueTransactionId>mytransid</uniqueTransactionId>
</ns2:TrackingMessageHeader>
<ns2:SecurityMessageHeader>
<userName>myusername</userName>
<userPassword>mypass</userPassword>
</ns2:SecurityMessageHeader>
<ns2:SequenceMessageHeader>
<sequenceNumber/>
<totalInSequence/>
</ns2:SequenceMessageHeader>
</ns2:MessageHeader>';
my $rawxmlrequest = '<OrderSearchCriteria>
<OrderDetails>
<SearchByOrderAction>
<orderActionNumber>12345654</orderActionNumber>
<orderActionVersion>1</orderActionVersion>
</SearchByOrderAction>
</OrderDetails>
</OrderSearchCriteria>
<provisioningDetailsIndicator>true</provisioningDetailsIndicator>';
my $client = SOAP::Lite->new( proxy => "$serviceURL");
my $header = SOAP::Header->type('xml' => $rawxmlheader);
my $elem = SOAP::Data->type('xml' => $rawxmlrequest);
my #arguments;
push(#arguments, $header);
push(#arguments, $elem);
my $reply = $client->InquireEnterpriseOrderDataRequest(#arguments);
This produced a very similar request to what was needed with the exception that the InquireEnterpriseOrderDataRequest blob did not contain the xsi:schemaLocation, xmlns or xmlns:xsi values that seem to be required.
Try #3:
Now I was grasping at straws, so I also tried to granularly create my own XML using something like this:
my $temp_elements =
SOAP::Data->name("OrderSearchCriteria" => \SOAP::Data->value(
SOAP::Data->name("OrderDetails" => \SOAP::Data->value(
SOAP::Data->name("SearchByOrderAction" => \SOAP::Data->value(
SOAP::Data->name("orderActionNumber" => '301496944'),
SOAP::Data->name("orderActionVersion" => '3')
)
)
)
))
)->type("SomeObject");
my $client = SOAP::Lite->new( proxy => "$serviceURL");
my $reply = $client->InquireEnterpriseOrderDataRequest($temp_elements);
The problem here was that I don't know how to include the xsi:schemaLocation, xmlns and xmlns:xsi values or prepend the header information.
Of course, I'd like to go with the simplest possible implementation but any suggestions are appreciated! Thanks in advance!
Required request format:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<ns2:MessageHeader xmlns:ns2="http://mycompany.com/MessageHeader.xsd" xmlns="http://mycompany.com/CingularDataModel.xsd">
<ns2:TrackingMessageHeader>
<version>111</version>
<originalVersion/>
<messageId/>
<originatorId>ABC</originatorId>
<responseTo/>
<returnURL/>
<timeToLive>360000</timeToLive>
<conversationId>9AF0E9281A524262980F5284F4C57888_CCE423E277C74FA9A84D2155CD612EB3_0</conversationId>
<routingRegionOverride/>
<dateTimeStamp>2017-04-11T18:47:53Z</dateTimeStamp>
<uniqueTransactionId>mytransid</uniqueTransactionId>
</ns2:TrackingMessageHeader>
<ns2:SecurityMessageHeader>
<userName>myusername</userName>
<userPassword>mypass</userPassword>
</ns2:SecurityMessageHeader>
<ns2:SequenceMessageHeader>
<sequenceNumber/>
<totalInSequence/>
</ns2:SequenceMessageHeader>
</ns2:MessageHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<InquireEnterpriseOrderDataRequest xsi:schemaLocation="http://mycompany.com/InquireEnterpriseOrderDataRequest.xsd" xmlns="http://mycompany.com/InquireEnterpriseOrderDataRequest.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OrderSearchCriteria>
<OrderDetails>
<SearchByOrderAction>
<orderActionNumber>12345654</orderActionNumber>
<orderActionVersion>1</orderActionVersion>
</SearchByOrderAction>
</OrderDetails>
</OrderSearchCriteria>
<provisioningDetailsIndicator>true</provisioningDetailsIndicator>
</InquireEnterpriseOrderDataRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This should generate the required response using SOAP::Lite request.
use strict;
use warnings;
use SOAP::Lite +trace=>'all';
$on_action = '';
$proxy = 'http://serviceURL';
$soap = SOAP::Lite->new(proxy => $proxy);
$soap->on_action(sub {$on_action});
$soap->readable(1);
$soap->autotype(0);
$soap->serializer->register_ns('http://mycompany.com/InquireEnterpriseOrderDataRequest.xsd' => 'xsi');
$soap->serializer->register_ns('http://mycompany.com/InquireEnterpriseOrderDataRequest.xsd' => 'xsi:schemaLocation');
$soap->default_ns('http://mycompany.com/InquireEnterpriseOrderDataRequest.xsd');
$soap->envprefix('SOAP-ENV');
$sheader = SOAP::Header->name(MessageHeader =>\SOAP::Header->value(SOAP::Header->name(TrackingMessageHeader => \SOAP::Header->value(
SOAP::Header->name(version => 111),
SOAP::Header->name(originalVersion => ''),
SOAP::Header->name(messageId => ''),
SOAP::Header->name(originatorId => 'ABC'),
SOAP::Header->name(responseTo => ''),
SOAP::Header->name(returnURL => ''),
SOAP::Header->name(timetoLive => 360000),
SOAP::Header->name(conversationId => '9AF0E9281A524262980F5284F4C57888_CCE423E277C74FA9A84D2155CD612EB3_0'),
SOAP::Header->name(routingRegionOverride => ''),
SOAP::Header->name(dateTimeStamp => '2017-04-11T18:47:53Z'),
SOAP::Header->name(timetoLive => 'mytransid'),
))->prefix('ns2')))->attr({'xmlns:ns2' => 'http://mycompany.com/MessageHeader.xsd',xmlns => 'http://mycompany.com/CingularDataModel.xsd'})->prefix('ns2');
push #request,(
SOAP::Data->name(OrderSearchCriteria => \SOAP::Data->value(
SOAP::Data->name(OrderDetails => \SOAP::Data->value(
SOAP::Data->name(SearchByOrderAction => \SOAP::Data->value(
SOAP::Data->name(orderActionNumber => 12345654),
SOAP::Data->name(orderActionVersion => 1),
)))))));
$reply = $soap->InquireEnterpriseOrderDataRequest($sheader,#request);

Using Guzzle to consume SOAP

I'm loving the Guzzle framework that I just discovered. I'm using it to aggregate data across multiple API's using different response structures. It's worked find with JSON and XML, but one the services i need to consume uses SOAP. Is there a built-in way to consume SOAP services with Guzzle?
You can get Guzzle to send SOAP requests.
Note that SOAP always has an Envelope, Header and Body.
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<NormalXmlGoesHere>
<Data>Test</Data>
</NormalXmlGoesHere>
</soapenv:Body>
The first thing I do is build the xml body with SimpleXML:
$xml = new SimpleXMLElement('<NormalXmlGoesHere xmlns="https://api.xyz.com/DataService/"></NormalXmlGoesHere>');
$xml->addChild('Data', 'Test');
// Removing xml declaration node
$customXML = new SimpleXMLElement($xml->asXML());
$dom = dom_import_simplexml($customXML);
$cleanXml = $dom->ownerDocument->saveXML($dom->ownerDocument->documentElement);
We then wrap our xml body with the soap envelope, header and body.
$soapHeader = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>';
$soapFooter = '</soapenv:Body></soapenv:Envelope>';
$xmlRequest = $soapheader . $cleanXml . $soapFooter; // Full SOAP Request
We then need to find out what our endpoint is in the api docs.
We then build the client in Guzzle:
$client = new Client([
'base_url' => 'https://api.xyz.com',
]);
try {
$response = $client->post(
'/DataServiceEndpoint.svc',
[
'body' => $xmlRequest,
'headers' => [
'Content-Type' => 'text/xml',
'SOAPAction' => 'https://api.xyz.com/DataService/PostData' // SOAP Method to post to
]
]
);
var_dump($response);
} catch (\Exception $e) {
echo 'Exception:' . $e->getMessage();
}
if ($response->getStatusCode() === 200) {
// Success!
$xmlResponse = simplexml_load_string($response->getBody()); // Convert response into object for easier parsing
} else {
echo 'Response Failure !!!';
}
IMHO Guzzle doesn't have full SOAP support and works only with HTTP requests.
src/Guzzle/Http/ClientInterface.php Line:76
public function createRequest(
$method = RequestInterface::GET,
$uri = null,
$headers = null,
$body = null,
array $options = array()
);
Even if SOAP server is configured to negotiate on port 80 I think php SoapClient is more appropriate solution here as it supports WSDL
Old Topic, but as I was searching for the same answer, it seems async-soap-guzzle is doing the job.
Guzzle HTTP can be used for SOAP requests & works like a charm:
Below is the way I have implemented.
Create variables:
public function __construct(Request $request) {
$this->request = $request;
$this->openSoapEnvelope = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">';
$this->soapHeader = '<soap:Header>
<tem:Authenticate>
<-- any header data goes here-->
</tem:Authenticate>
</soap:Header>';
$this->closeSoapEnvelope = '</soap:Envelope>';
}
Create a function to form a soap request.
public function generateSoapRequest($soapBody){
return $this->openSoapEnvelope . $this->soapHeader . $soapBody . $this->closeSoapEnvelope;
}
Define a body & call generateSoapRequest method.
e.g:
$soapBody = '<soap:Body>
<tem:GetSomeDetails/>
</soap:Body>';
$xmlRequest = $this->generateSoapRequest($soapBody);
$client = new Client();
$options = [
'body' => $xmlRequest,
'headers' => [
"Content-Type" => "text/xml",
"accept" => "*/*",
"accept-encoding" => "gzip, deflate"
]
];
$res = $client->request(
'POST',
'http://your-soap-endpoint-url',
$options
);
print_r($res->getBody());

Zend Soap Client tag names

I'm trying to connect a .net WSDL service with Zend Soap Client. I use the code below;
$client = new Zend_Soap_Client("http://ws.test.com/test/services/service.asmx", array(
'uri' => 'http://tempuri.org',
'soap_version' => SOAP_1_1,
'wsdl' => 'http://ws.test.com/test/services/service.asmx?wsdl'
));
$client->DoInventoryItemImport(array(
'DepositorID_' => '123',
'UserName_' => 'ABC',
'Password_' => '123123',
'SecurityKey_' => '',
'ContinueOnError_' => true,
'Items_' => array(
'InventoryItem' => array(
'Code' => 'testcode',
'Description' => 'test description',
'Abccode' => 'test',
'Weight' => 10.10,
'ItemMainCategory' => 'testCategory',
'Depositor' => 'ABC',
'DepositorCode' => '123'
)
)
));
This code sends a soap envelope exactly like this one;
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:DoInventoryItemImport>
<ns1:Items_>
<ns1:InventoryItem>
<ns1:Code>testcode</ns1:Code>
<ns1:Description>test description</ns1:Description>
<ns1:Abccode>test</ns1:Abccode>
<ns1:AllocatesAgainstQCPolicy xsi:nil="true"/>
<ns1:SafetyStockCU xsi:nil="true"/>
<ns1:TemplateItem xsi:nil="true"/>
<ns1:MinimumOrderQTY xsi:nil="true"/>
<ns1:IsLoadBatch xsi:nil="true"/>
<ns1:Weight>10.1</ns1:Weight>
<ns1:Volume xsi:nil="true"/>
<ns1:Diameter xsi:nil="true"/>
<ns1:IsTemporaryItem xsi:nil="true"/>
<ns1:IsKitItem xsi:nil="true"/>
<ns1:ItemMainCategory>testCategory</ns1:ItemMainCategory>
<ns1:IsFragile xsi:nil="true"/>
<ns1:IsPackingItem xsi:nil="true"/>
<ns1:Depositor>ABC</ns1:Depositor>
<ns1:DepositorCode>123</ns1:DepositorCode>
</ns1:InventoryItem>
</ns1:Items_>
<ns1:UserName_>ABC</ns1:UserName_>
<ns1:Password_>123123</ns1:Password_>
<ns1:SecurityKey_></ns1:SecurityKey_>
<ns1:ContinueOnError_>true</ns1:ContinueOnError_>
</ns1:DoInventoryItemImport>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But as I understand from their service definition, they want a soap envelope like this one;
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DoInventoryItemImport xmlns="http://tempuri.org/">
<Items_>
<InventoryItem>
<Code>testcode</Code>
<Description>test description</Description>
<Abccode>test</Abccode>
<AllocatesAgainstQCPolicy>true</AllocatesAgainstQCPolicy>
<SafetyStockCU>1</SafetyStockCU>
<TemplateItem>true</TemplateItem>
<MinimumOrderQTY>1</MinimumOrderQTY>
<IsLoadBatch>true</IsLoadBatch>
<Weight>10.1</Weight>
<Volume>1</Volume>
<Diameter>1</Diameter>
<IsTemporaryItem>true</IsTemporaryItem>
<IsKitItem>true</IsKitItem>
<ItemMainCategory>testCategory</ItemMainCategory>
<IsFragile>true</IsFragile>
<IsPackingItem>true</IsPackingItem>
<Depositor>ABC</Depositor>
<DepositorCode>123</DepositorCode>
</InventoryItem>
</Items_>
<UserName_>ABC</UserName_>
<Password_>123123</Password_>
<SecurityKey_></SecurityKey_>
<ContinueOnError_>true</ContinueOnError_>
</DoInventoryItemImport>
</soap:Body>
</soap:Envelope>
Actually these envelopes contains same data and their structure matches. But I don't know how to change tag names like SOAP-ENV to soap and remove prefixes like "ns1:".
I think I am misconfiguring my Zend Soap Client?
I solved this by overloading Zend Soap Client. I used str_ireplace function to replace 'ns1:' with '' on request variable. Then I used my custom client to connect. Hope this helps to somebody.
class My_Client extends Zend_Soap_Client_DotNet{
public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null)
{
if ($one_way == null) {
return call_user_func(array($client,'SoapClient::__doRequest'), str_ireplace('ns1:', '', $request), $location, $action, $version);
} else {
return call_user_func(array($client,'SoapClient::__doRequest'), str_ireplace('ns1:', '', $request), $location, $action, $version, $one_way);
}
}
}

Soap: Upload binary data

I'm making a Drupal/PHP Module to upload information to Taleo (Talent Management) database using SOAP. This works well with regular data like text and dates, but not with a file.
The manual shows an example of a file attachment:
createAttachment Test Case:
<soapenv:Header/>
<soapenv:Body>
<urn:createAttachment>
<in0>webapi-5616904436472928038</in0>
<in1>15</in1>
<in2>test1.docx</in2>
<in3>test1.docx</in3>
<in4>application/vnd.openxmlformatsofficedocument.
wordprocessingml.document</in4>
<in5>
<!--type: base64Binary-->
<array>JVBERi0xLjQNJeLjz9MNCjYgMCBvYmogPDwvTGluZWFyaX==</array>
</in5>
</urn:createAttachment>
</soapenv:Body>
</soapenv:Envelope>
So I made a PHP file like this:
// Send attachment
$fileName = drupal_get_path('module', 'taleo') . '/test.txt';
$rawFile = fread(fopen($fileName, "r"), filesize($fileName));
$B64File = base64_encode($rawFile);
$params = array(
'in0' => $session,
'in1' => $candidate_id,
'in2' => 'test.txt',
'in3' => 'test.txt',
'in4' => 'text/plain',
'in5' => $B64File
);
$client_taleo->__call('createAttachment', $params);
When I do "echo $B64File" I get this: RmlsZSB1cGxvYWQgd2l0aCBEcnVwYWwgIQ==, so the file is being read correct.
But I always get this error:
ERROR: soapenv:Server.generalException-attBinDataArr is null.
Any ideas?
You forgot to encapsulate the base64-data in array-tags.
<array>JVBERi0xLjQNJeLjz9MNCjYgMCBvYmogPDwvTGluZWFyaX==</array>
Something like this should work:
$params = array(
'in0' => $session,
'in1' => $candidate_id,
'in2' => 'test.txt',
'in3' => 'test.txt',
'in4' => 'text/plain',
'in5' => array('array' => $B64File)
);
It was clear I had to do something with the array-tag, that's for sure.
The answer above deserves an "upvote", so I gave it one. But I found the correct answer myself... After a few seconds of "logic" thinking. :)
'in5' => array('array' => $B64File)

SoapFault exception: [HTTP] Bad Request In eway

I am going to integrate the eway token payment integration and i am facing this problem.
SoapFault exception: [HTTP] Bad Request
the wsdl file is here
https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx?wsdl
and the xml format is here
https://www.eway.com.au/gateway/ManagedPaymentService/test/managedcreditcardpayment.asmx?op=CreateCustomer
and i get the xml file with $client->__getLastRequest(); script is
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="https://www.eway.com.au/gateway/managedpayment" xmlns:ns2="eWAYHeader">
<env:Header>
<ns2:http://www.eway.com.au/gateway/managedPayment>
<item>
<key>eWAYCustomerID</key><value>87654321</value>
</item>
<item><key>Username</key><value>test#eway.com.au</value>
</item>
<item><key>Password</key><value>test123</value>
</item>
</ns2:http://www.eway.com.au/gateway/managedPayment>
</env:Header><env:Body>
<ns1:CreateCustomer>
<ns1:Title>Mr.</ns1:Title>
<ns1:FirstName>Joe</ns1:FirstName>
<ns1:LastName>Bloggs</ns1:LastName>
<ns1:Address>Bloggs Enterprise</ns1:Address>
<ns1:Suburb>Capital City</ns1:Suburb>
<ns1:State>ACT</ns1:State>
<ns1:Company>Bloggs</ns1:Company>
<ns1:PostCode>2111</ns1:PostCode>
<ns1:Country>au</ns1:Country>
<ns1:Email>test#eway.com.au</ns1:Email>
<ns1:Fax>0298989898</ns1:Fax>
<ns1:Phone>0297979797</ns1:Phone>
<ns1:Mobile>9841381980</ns1:Mobile>
<ns1:CustomerRef>Ref123</ns1:CustomerRef>
<ns1:JobDesc>Web developer</ns1:JobDesc>
<ns1:Comments>Please Ship ASASP</ns1:Comments>
<ns1:URL>http://www.test.com.au</ns1:URL>
<ns1:CCNumber>4444333322221111</ns1:CCNumber>
<ns1:CCNameOnCard>Test Account </ns1:CCNameOnCard>
<ns1:CCExpiryMonth>1</ns1:CCExpiryMonth>
<ns1:CCExpiryYear>13</ns1:CCExpiryYear>
</ns1:CreateCustomer>
</env:Body>
</env:Envelope>
Is there both xml structure effets to soap:
Or is this something like problem of soap header?
i have set header like this
$data = array('eWAYCustomerID'=>'87654321',
'Username' => "test#eway.com.au",
'Password' => "test123"
);
$header = new SoapHeader('eWAYHeader',$url,$data);
$client->__setSoapHeaders($header);
I am getting:
SoapFault exception: [HTTP] Bad Request in D:\wamp\www\eway\newfile.php:196
Stack trace:
#0 [internal function]: SoapClient->__doRequest('__call('CreateCustomer', Array)
#2 D:\wamp\www\eway\newfile.php(196): SoapClient->CreateCustomer(Array)
#3 {main}
This error always while i call this function
$customerinfo =
array(
'Title'=>'Mr.',
'FirstName' => 'Joe',
'LastName'=>'Bloggs',
'Address'=>'Bloggs Enterprise',
'Suburb'=>'Capital City',
'State'=>'ACT',
'Company'=>'Bloggs',
'PostCode'=>'2111',
'Country'=>'au',
'Email'=>'test#eway.com.au',
'Fax'=>'0298989898',
'Phone'=>'0297979797',
'Mobile'=>'9841381980',
'CustomerRef'=>'Ref123',
'JobDesc'=>'Web developer',
'Comments'=>'Please Ship ASASP',
'URL'=>'http://www.test.com.au',
'CCNumber'=>'4444333322221111',
'CCNameOnCard'=>'Test Account ',
'CCExpiryMonth'=>'01',
'CCExpiryYear'=>'13'
);
$client->CreateCustomer($customerinfo);
Any help will be more valuable.
Thanks in advance.
Try to use the following code instead:
<?php
$apiUrl = 'https://www.eway.com.au/gateway/ManagedPaymentService/test/managedcreditcardpayment.asmx?WSDL';
$options = array( 'trace' => 1, 'exceptions' => 1);
try{
$client = new SoapClient($apiUrl, $options);
$data = array(
'eWAYCustomerID' => '87654321',
'Username' => "test#eway.com.au",
'Password' => "test123"
);
$header = new SoapHeader('https://www.eway.com.au/gateway/managedpayment', 'eWAYHeader', $data, false);
$client->__setSoapHeaders($header);
$customerinfo = array(
'Title'=>'Mr.',
'FirstName' => 'Joe',
'LastName'=>'Bloggs',
'Address'=>'Bloggs Enterprise',
'Suburb'=>'Capital City',
'State'=>'ACT',
'Company'=>'Bloggs',
'PostCode'=>'2111',
'Country'=>'au',
'Email'=>'test#eway.com.au',
'Fax'=>'0298989898',
'Phone'=>'0297979797',
'Mobile'=>'9841381980',
'CustomerRef'=>'Ref123',
'JobDesc'=>'Web developer',
'Comments'=>'Please Ship ASASP',
'URL'=>'http://www.test.com.au',
'CCNumber'=>'4444333322221111',
'CCNameOnCard'=>'Test Account ',
'CCExpiryMonth'=>'01',
'CCExpiryYear'=>'13'
);
$result = $client->CreateCustomer($customerinfo);
var_dump($result);
}catch(Exception $e){
echo $e->getMessage();
}
which worked for me.
Notes:
1. Always try to wrap the code in try{} catch{} block
2. Make sure to check php_openssl extension is enabled or not
3. Disable the wsdl cache & enable the exceptions
4. Note the SoapHeader constructor.
Hope this helps you.
Regards