• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7353
  • Last Modified:

How to use PHP5 SoapClient using GoDaddy's proxy

I need to connect to Vertical Response's web service with PHP5 and the built in SOAP client.
The problem is that GoDaddy requires HTTPS connections to go through a proxy and I don't know how to do it.
Here is the code I'm using:

<?php
error_reporting(E_ALL);

$wsdl = "https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl";
$user = "test_user";
$pass = "test_pass";

$vr = new SoapClient($wsdl);

$session_id = $vr->login(array('username' => $user, 'password' => $pass, 'session_duration_minutes' => $ses_time));

echo("session id: $session_id\n");
?>

The proxy info is the following:
PROXY HOST: http://proxy.shr.secureserver.net
PROXY PORT: 3128

If anyone knows how to do this, please let me know.

Thanks,
Poisa.
0
poisa
Asked:
poisa
  • 2
2 Solutions
 
hernst42Commented:
See http://www.php.net/manual/en/function.soap-soapclient-construct.php

For making an HTTP connection through a proxy server, use the options proxy_host, proxy_port, proxy_login  and proxy_password.
0
 
poisaAuthor Commented:
hernst42, thanks for the prompt answer. I had already looked it up in the php docs and knew about the extra parameters but the error response I keep getting is the same with or without the extra parameters. Just for the record, this is the code I tried with the proxy stuff in there (this code fails to connect, too):

<?php
error_reporting(E_ALL);

$wsdl = "https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl"; //location of the wsdl
$user = "test_user"; // VR usernaname
$pass = "test_pass"; //VR passowrd

$soapOptions = array (
    "proxy_host" => 'http://proxy.shr.secureserver.net',
    "proxy_port" => '3128',
    'proxy_login'    => "",
    'proxy_password' => "",
);

$vr = new SoapClient($wsdl, $soapOptions);

$session_id = $vr->login(array('username' => $user, 'password' => $pass, 'session_duration_minutes' => $ses_time));

echo("session id: $session_id\n");
?>

What bugs me is that I am positive that the proxy works and does not require any authentication because if I try a simple cURL request to an HTTPS address I can connect without a problem. The same request without the proxy fails miserably.

Also for the record, here is the error message the above code outputs:

Warning: SoapClient::__construct(https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl) [function.SoapClient---construct]: failed to open stream: Connection timed out in /home/content/v/2/m/v2mailing/html/clean_test.php on line 17

Warning: SoapClient::__construct() [function.SoapClient---construct]: I/O warning : failed to load external entity "https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl" in /home/content/v/2/m/v2mailing/html/clean_test.php on line 17

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.verticalresponse.com/wsdl/1.0/VRAPI.wsdl' in /home/content/v/2/m/v2mailing/html/clean_test.php:17 Stack trace: #0 /home/content/v/2/m/v2mailing/html/clean_test.php(17): SoapClient->__construct('https://api.ver...', Array) #1 {main} thrown in /home/content/v/2/m/v2mailing/html/clean_test.php on line 17
0
 
tkalchevCommented:
Hi,

you should remove the protocol prefix from the proxy_host parameter, there you must provide a host name or an IP address, not an URL. So change

$soapOptions = array (
    "proxy_host" => 'http://proxy.shr.secureserver.net',
    "proxy_port" => '3128',
    'proxy_login'    => "",
    'proxy_password' => "",
);

to

$soapOptions = array (
    "proxy_host" => 'proxy.shr.secureserver.net',
    "proxy_port" => '3128',
    'proxy_login'    => "",
    'proxy_password' => "",
);
0
 
poisaAuthor Commented:
Hi again guys and thanks for the help.

Actually both of you were on the right track so I'm splitting points and giving an A grade to both.

The final solution consisted in using this code:

$soapOptions = array (
    'proxy_host' => 'proxy.shr.secureserver.net',
    'proxy_port' => 3128,
    'proxy_login'    => '',
    'proxy_password' => '',
);

Note that the port parameter is of tyep INT as opposed to STRING (which was what I erroneously was trying).

Hope this helps any other GoDaddyers.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now