SOAP call to WisePay WSDL from PHP

Hello,

I'm trying to make use of an API with this service provider to submit student data, presented as XML.  I am confident that the XML itself is correctly constructed, but am not overly familiar with the PHP SoapClient class.

The WSDL I'm using is this:

https://www.wisepay.co.uk/services/WP_Account_Import_ws.asmx?WSDL

This has an 'xmltext' element, into which I'm trying to pass the constructed XML as a parameter.  I believe it is this bit that is not working, since a dump of the SOAP Request does not contain said content.  The error I'm getting back from the web service is "Failed XML Initialisation", which I think supports this theory.

I'm running PHP 5.4 on Windows Server 2012 R2 (IIS 8.5).

My PHP code follows.  $xmltext is soundly constructed XML.  The commented code are alternatives I've already tried.

If anyone has any tips to assist, I'd be grateful to hear them.

-----
$soap_client_options = array(       'trace'=>1
                                          ,'soap_version'=>SOAP_1_1
                                    );

$client = new SoapClient('https://www.wisepay.co.uk/services/WP_Account_Import_ws.asmx?WSDL', $soap_client_options);

/*
class WisePaySubmission {
      public $xmltext;
}

$wps = new WisePaySubmission();
$wps->xmltext = $xmltext;

$params = array(
       $wps
);
*/

$params = array(
       "xmltext"=>$xmltext
);


// Invoke webservice method
$response = $client->WisePaySendAccounts (array($params));

// Also tried...
//$response = $client->__soapCall("WisePaySendAccounts", array($params));


// Print webservice response
print_r($client->__getFunctions());
print_r($client->__getTypes());
echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "\n";
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
var_dump($response);
-----



A dump of the headers, constructed SOAP request and response follows:

----
REQUEST HEADERS:
POST /services/WP_Account_Import_ws.asmx HTTP/1.1
Host: www.wisepay.co.uk
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.14
Content-Type: text/xml; charset=utf-8
SOAPAction: "https://www.wisepay.co.uk/WP_Account_Import_ws/WisePaySendAccounts"

Content-Length: 254


REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xm
lns:ns1="https://www.wisepay.co.uk/WP_Account_Import_ws"><SOAP-ENV:Body><ns1:Wis
ePaySendAccounts/></SOAP-ENV:Body></SOAP-ENV:Envelope>

RESPONSE:
object(stdClass)#1 (1) {
  ["WisePaySendAccountsResult"]=>
  string(26) "Failed XML Initialisation"
}
------
LVL 1
Anglian Learning Technical ServicesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Slick812Commented:
greetings bottishamvc, , I have done some SOAP connections in PHP, and they are a difficult to understand PHP set of code and Object methods, I looked at your  WSDL XML at -
   https://www.wisepay.co.uk/services/WP_Account_Import_ws.asmx?WSDL

This seems to be an XML TEXT submission Object definition.

and the "WisePaySubmission" , seems to be a TYPE definition a WSDL element, maybe not a Method.,

I feel that methods are WSDL operations, as a part of a service.

For the most part, the best way, and sometimes the only way to do successful PHP SOAP transactions, is to get the PHP code example from the Soap service, as -
   https://www.wisepay.co.uk/
in your case, I tried to find the PHP code there for this education payment service SOAP definitions, but could not find any. BUT they do say that you can get them to do, or help you to do, the SERVER code needed for their SOAP service.

You might contact them here -
   https://www.wisepay.co.uk/web/training_and_support/default.asp#
0
Anglian Learning Technical ServicesAuthor Commented:
Thank you.  Unfortunately, Wisepay only offer a framework in ASPX, not our preferred PHP.  I have got another of their APIs working, in the form of an SSO solution, just not this one.
0
Slick812Commented:
In your code you have two things that may help in using this WSDL -
     $client->__getTypes()
     $client->__getFunctions()

If the WSDL has valid organization for it's objects and types definitions, the __getFunctions( )  can list the object structures linked to the method names with the TYPES for the method parameters, and the TYPE of the return, ,  that are available in that soap connection.

Unfortunately in PHP, the parameters of the TYPES can be confusing, as in PHP you can sometimes use PHP Arrays (with name=>value pairs) instead of PHP objects (with name=>value pairs). There there is the confusion (at least its confusing to me) about using the PHP -
   new SoapVar( )
or using a constructed  name=>value  array.

In your WSDL there are -
   <wsdl:binding

which adds (binds) to the SOAP object more methods and or types, or child (sub) objects.

you may can look at the ASP code to see how it uses the Object connections (child and or sub objects), as I have said, you can just do trial and error PHP code tests and read the error messages to try and get working code, or ask the wisepay people for some sort of PHP , help, there must be someone to use this in PHP before?
I wish I could be more help, but I do not have the experience to just read a WSDL definition like -
   https://www.wisepay.co.uk/services/WP_Account_Import_ws.asmx?WSDL

and know what the objects methods and types are for PHP.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anglian Learning Technical ServicesAuthor Commented:
Thanks, Slick812,

It turned out that I needed to add an extra dimension to the method parameter, like so:

$params = array(
      "xmltext"=>array ("any"=>$xmltext)
);

These tiny little misunderstandings can end up being so time consuming!

Thanks very much for your advice.  I've now completed the upload script and also have their SSO offering functional, so I'm grateful.

In reference to your reflection over someone must having already done this, they claim not!  I have now offered myself as a reference if anyone else approaches them about the same thing.

Many thanks,

Richard
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.