Need help to send XML to WebService

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EddiRae
Forum Newbie
Posts: 9
Joined: Fri Jun 19, 2009 11:00 am

Need help to send XML to WebService

Post by EddiRae »

Hello,
I am VERY new to PHP (just started learning) and I need help.

I have a project that needs to send XML to an existing webservice.
The XML template is as follows:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
 <Transmission>
  <EdProviderData>
    <DetailData>
      <Detail>
    <IN_PROV>1234</IN_PROV>
    <IN_CRSE>2345</IN_CRSE>
    <IN_CDATE>03242009</IN_CDATE>
    <IN_ZIP>12345</IN_ZIP>
    <IN_LICENSE>1234567</IN_LICENSE>
    <IN_NAME>John Doe (test only)</IN_NAME>
      </Detail>
    </DetailData>
  </EdProviderData>
 </Transmission>
 
The owner of the webservice gave me the authentication request in ASP.NET, but I am needing to run this in PHP. I will have variables for the XML to change the values in the <IN_?> fields.

The webservice is expecting a security token.

What would you suggest in accomplishing this?

Thanks for your help in advance!!
Eddi Rae
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Need help to send XML to WebService

Post by requinix »

For the XML just change the values you need.

Code: Select all

$xml = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
 <Transmission>
  <EdProviderData>
    <DetailData>
      <Detail>
        <IN_PROV>$inprov</IN_PROV>
        <IN_CRSE>$incrse</IN_CRSE>
        <IN_CDATE>$incdate</IN_CDATE>
        <IN_ZIP>$inzip</IN_ZIP>
        <IN_LICENSE>$inlicense</IN_LICENSE>
        <IN_NAME>$inname</IN_NAME>
      </Detail>
    </DetailData>
  </EdProviderData>
 </Transmission>
 XML;
For the authentication, dunno. You haven't told us how that works.
EddiRae
Forum Newbie
Posts: 9
Joined: Fri Jun 19, 2009 11:00 am

Re: Need help to send XML to WebService

Post by EddiRae »

Thanks for your input!!!
Here is the WebService information in .NET. How would you set the token in PHP?

• The ProcessRoster web service’s WSDL is located at:

https://<website>/ProcessEdRoster/Service1.asmx?wsdl

• The formats of the xml (request and response) is noted in the attachments
• Our authentication requires a security token. Your application should reference this from a config file (as I am sure this will periodically change). Please note the snippet of code (C# .Net) to instantiate the authentication class and set the token:

WebReferenceName.ValidationSoapHeader hdr =
new WebReferenceName.ValidationSoapHeader();
hdr.DevToken = "12345";


• Instantiation and request of the web service (snippet of code):

WebReferenceName.Service1 ws =
new WebReferenceName.Service1();
WebReferenceName.ProcessRoster(“your xml request”);
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Need help to send XML to WebService

Post by requinix »

Good question. .NET stuff is pretty opaque.

I suspect that you might have to use SOAP to do this, which kinda helps with handling authentication.
Post Reply