Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

sending a SOAP request with php


  • Please log in to reply
3 replies to this topic

#1 bmett

bmett

    CC Newcomer

  • Just Joined
  • PipPip
  • 12 posts

Posted 20 June 2010 - 10:02 PM

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.

  • 0

#2 bmett

bmett

    CC Newcomer

  • Just Joined
  • PipPip
  • 12 posts

Posted 22 June 2010 - 03:56 PM

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
  • 0

#3 NoelLimpag

NoelLimpag

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 20 November 2012 - 08:52 PM

Hello.. i got the same problem, and i am also newbie(really knows nothing) to soap.. so here is the sample request they gave:

SOAP 1.1

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /webservicev2/wscheckoutpayment.asmx HTTP/1.1
Host: mmpay.evertecinc.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/WebMerchant/MerchantService/MakePayment"
<?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>
<MakePayment xmlns="http://tempuri.org/WebMerchant/MerchantService">
	 <Username>string</Username>
	 <Password>string</Password>
	 <CustomerName>string</CustomerName>
	 <CustomerID>string</CustomerID>
	 <CustomerEmail>string</CustomerEmail>
	 <Total>string</Total>
	 <DescriptionBuy>string</DescriptionBuy>
	 <TaxAmount1>string</TaxAmount1>
	 <address1>string</address1>
	 <address2>string</address2>
	 <city>string</city>
	 <zipcode>string</zipcode>
	 <telephone>string</telephone>
	 <fax>string</fax>
	 <ignoreValues>string</ignoreValues>
	 <language>string</language>
	 <TaxAmount2>string</TaxAmount2>
	 <TaxAmount3>string</TaxAmount3>
	 <TaxAmount4>string</TaxAmount4>
	 <TaxAmount5>string</TaxAmount5>
	 <filler1>string</filler1>
	 <filler2>string</filler2>
	 <filler3>string</filler3>
</MakePayment>
</soap:Body>
</soap:Envelope>


and response:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?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>
<MakePaymentResponse xmlns="http://tempuri.org/WebMerchant/MerchantService">
<MakePaymentResult>string</MakePaymentResult>
</MakePaymentResponse>
</soap:Body>
</soap:Envelope>


Questions:
1. How can i send the Request?
2. How can i send the header?
3. How can i receive the response?
  • 0

#4 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 20 November 2012 - 11:49 PM

You can the request through HttpPost or use the following url:
http://www.php.net/m...en/ref.soap.php

You can also use Soap Client and call its method ... check out:
http://www.php.net/m....soapclient.php
  • 0

www.pickmike.com
I don't just develop software. I find solutions to your business needs.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download