Jump to content

sending a SOAP request with php

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
bmett

bmett

    Newbie

  • Members
  • PipPip
  • 12 posts
Hello everyone,

I need to send a SOAP request to a certain webservice and already struggle in creating the request.
Here is how the request should look like:

POST /gateway/rebill/test/manageRebill_test.asmx HTTP/1.1

Host: www.eway.com.au

Content-Type: application/soap+xml; charset=utf-8

Content-Length: length


<?xml version="1.0" encoding="utf-8"?>

<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">

  <soap12:Header>

    <eWAYHeader xmlns="http://www.eway.com.au/gateway/rebill/manageRebill">

      <eWAYCustomerID>string</eWAYCustomerID>

      <Username>string</Username>

      <Password>string</Password>

    </eWAYHeader>

  </soap12:Header>

  <soap12:Body>

    <CreateRebillEvent xmlns="http://www.eway.com.au/gateway/rebill/manageRebill">

      <RebillCustomerID>string</RebillCustomerID>

      <RebillInvRef>string</RebillInvRef>

      <RebillInvDes>string</RebillInvDes>

      <RebillCCName>string</RebillCCName>

      <RebillCCNumber>string</RebillCCNumber>

      <RebillCCExpMonth>string</RebillCCExpMonth>

      <RebillCCExpYear>string</RebillCCExpYear>

      <RebillInitAmt>string</RebillInitAmt>

      <RebillInitDate>string</RebillInitDate>

      <RebillRecurAmt>string</RebillRecurAmt>

      <RebillStartDate>string</RebillStartDate>

      <RebillInterval>string</RebillInterval>

      <RebillIntervalType>string</RebillIntervalType>

      <RebillEndDate>string</RebillEndDate>

    </CreateRebillEvent>

  </soap12:Body>

</soap12:Envelope>


SOAP is new to me and I don't know where to start... maybe someone can give me a push in the right direction.

Cheers,
Bjorn

Edited by bmett, 22 June 2010 - 03:57 PM.


#2
bmett

bmett

    Newbie

  • Members
  • PipPip
  • 12 posts
Well since nobody could help me here, I had to help myself :)
And guess what? I got it to work. Here's my solution, maybe it'll be helpful for someone else:

I simply forgot to set the Header of the SOAP request correctly. Here is the code to create a new SOAP-client and to set the Header:

$client = new SoapClient("URI of the SOAP server ");


$header = new SoapHeader(

    'Namespace of the SOAP Header element',

    'eWAYHeader',

    array(

        'eWAYCustomerID' => 'string',

        'Username' => 'string',

        'Password' => 'string'

    )

);
After that I simply called the SOAP function 'CreateRebillCustomer' with the needed data in an array"

$client->CreateRebillCustomer(array('data.....'));
And thats basically it. If you put a var_dump around that call you can display the response of the call.

It's good to be able to figure something out after a long series of try-and-error. In the end the PHP manual was the way to got (as ususal):
PHP: SoapHeader::SoapHeader - Manual
PHP: SoapClient::SoapClient - Manual
etc.

Cheers,
Bjornn