Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Integrating Gravity Forms , Wordpress and SOAP WordPress

  • SOLVED

I am using a Gravity Form to gather information from our website.

I need to then post this to a third party site using a SOAP API call.

Gravity Forms has a GForm after submission call:


1 <?php
2 add_action("gform_after_submission_5", "after_submission", 10, 2);
3 ?>

As I understand it this would submit only form #5



This is an example from Gravity forms for a third party submission


01 <?php
02 add_action('gform_after_submission', 'post_to_third_party', 10, 2);
03 function post_to_third_party($entry, $form) {
04
05 $post_url = 'http://thirdparty.com';
06 $body = array(
07 'first_name' => $entry['1.3'],
08 'last_name' => $entry['1.6'],
09 'message' => $entry['3']
10 );
11
12 $request = new WP_Http();
13 $response = $request->post($post_url, array('body' => $body));
14
15 }
16 ?>



Here is the actual soap code that I need to use to update the third party site....

( The data in this example is hard coded. Of course, I would need to pull the entry information as above.


<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:CreateCustomer>
<tem:Account_Id>**accountid**</tem:Account_Id>
<tem:UserName>**username_for_authentication**</tem:UserName>
<tem:Password>**password***</tem:Password>
<tem:CompanyName>testcompany9</tem:CompanyName>
<tem:DomainName>www.testcompany9.com</tem:DomainName>
<tem:FirstName>testuser9</tem:FirstName>
<tem:LastName>testuser9</tem:LastName>
<tem:Email>[email protected]</tem:Email>
<tem:Phone>999-999-9999</tem:Phone>
<tem:UserPassword>abcde1234</tem:UserPassword>
<tem:AccountType>freetrial</tem:AccountType>
</tem:CreateCustomer>
</soapenv:Body>
</soapenv:Envelope>

This needs to be posted against

https://**URL**/**company**/api/**filename**.asmx?WSDL




I need to know the specific code that needs to be inserted into the specific file to get it to work. I can create and post the form if that helps.

Thanks!

Dave



Answers (3)

2012-09-26

Jurre Hanema answers:

You should really use the PHP 5 built-in [[LINK href="http://www.php.net/manual/en/class.soapclient.php"]]SoapClient[[/LINK]]. I am guessing the URL you gave, https://**URL**/**company**/api/**filename**.asmx?WSDL, points to a WSDL service description? If so, using the PHP SoapClient to call the service is pretty easy and goes like this:


$client = new SoapClient(
'https://**URL**/**company**/api/**filename**.asmx?WSDL',
array(
'soap_version' => SOAP_1_2
)
);

$client->CreateCustomer(
array(
'Account_Id' => '**accountid**',
'UserName' => '**username**',
// etc etc
)
);


I think you already know how to get the values from the GravityForm using the $entry-array and insert them in place of my hardcoded strings.

If there are any problems when calling the service, it can be helpful to test it in an application like SoapUI first.

Good luck!

2012-09-25

Arnav Joy answers:

see this article

http://www.0to5blog.com/creative/gravity-forms-submitting-forms-to-3rd-party-applications/

2012-09-25

Martin Pham answers:

please see this
[[LINK href="http://stackoverflow.com/questions/6585853/how-to-call-a-soap-web-service-from-a-wordpress-form"]]http://stackoverflow.com/questions/6585853/how-to-call-a-soap-web-service-from-a-wordpress-form[[/LINK]]


Martin Pham comments:

readmore article
[[LINK href="http://wpthemetutorial.com/2012/03/22/integrating-sugarcrm-with-gravity-forms/"]]http://wpthemetutorial.com/2012/03/22/integrating-sugarcrm-with-gravity-forms/[[/LINK]]

or question [[LINK href="http://wpquestions.com/question/showLoggedIn/id/1669"]]http://wpquestions.com/question/showLoggedIn/id/1669[[/LINK]]