Link to home
Start Free TrialLog in
Avatar of GaryKevinBanks
GaryKevinBanks

asked on

Sending and receiving XML

I'm a newbie with XML but have to incorporate send and recive chunks of infomation to and from a 3rd party, secure, server.

Have, sort of (!!), got to grips with XMLHTTPRequest object and have tested scripts and connections to and from test pages on my own server but now need to connect to and share data with a 3rd party in order to populate pages on my own site with dynamic data from the 3rd party.

Initially I need to authenticate my connection to the 3rd party befoe I can think of sending requests for further data sets so I have to send an initial handshake in the form of an element, with 1 attribute and one child element with 2 attributes all contained within one root <message> element.

This may be XML101 to some people but I'm really struggling to see the wood for the trees. Any assistance to get me going or reference to tutorials that I can take a look at would be REALLY welcomed.

Many thanks.

Gary
ASKER CERTIFIED SOLUTION
Avatar of mattayers08
mattayers08

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GaryKevinBanks
GaryKevinBanks

ASKER

Thanks Matt, all useful info. Have just scanned a few pages detailing curl but still in a bit of a quandry!

I can initiate the contact with the 3rd party server:

$connectURL = 'https://3rdpartyserver.name' ;
//  and then block out the http headers to, hopefully, just get xml
if ($mySession = curl_init($url)) {
curl_setopt($mySession, CURLOPT_HEADER, false);
curl_setopt($mySession, CURLOPT_RETURNTRANSFER, true);

but I'm not sure how to fire off my user details in order to authenticate a connection as required by the 3rd party. They require that I log on to authenticate a session in order to send me a sessionID that has to be used when sending over further requests during that session.

They are expecting an XML "handshake" like:
<message>
<callerRequest requestCode="authenticate">
<caller callerName="USERNAME" callerPassword="PASSWORD"/>
</callerRequest>
</message>

I can figure out how to send each element, but not how to include the attributes of each element (i.e. the 2 attributes of caller)! I think I must just be being dumb!!

Does that make sense?

Any thoughts or hints as to where I might look for an answer.

Thanks again for the input so far.

Regards
Gary
Oops! That shoulda been:

if ($mySession = curl_init($connectURL)) {
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks again Matt, just tried that and it gets the connection - just get a message about the xml not being well formed (!!). But at least that's a response. Proves that something is working if not what I expected.

Now I can thrash out how they think the simplest of XML is not well formed - obviously something they have hidden and don't share with their partners!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial