Invoking WSF/PHP Web Services Through Proxy

If you are behind a proxy server you need to configure your client to send the request through proxy. With WSF/PHP you can do it in two ways.

1. Setting proxy configuration in WSClient itself

You can use the ‘proxyHost’ and ‘proxyPort’ options to provide the proxy information through WSClient.

$client = new WSClient(array("to" => "http://my.external.host/service_url",
                  "proxyHost" => PROXY_HOST,
                  "proxyPort" => PROXY_PORT));

2. Use the axis2.xml

Change the axis2.xml to the following. (axis2.xml is in the wsf_c directory which is by default installed inside the php extension directory unless you specified it explicitly in your php.ini ‘wsf.home’ entry)

    <transportSender name="http" class="axis2_http_sender">
        <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
      <parameter name="xml-declaration" insert="false"/>
      <!--Here is where you set the proxy host and the port-->
      <parameter name="PROXY" proxy_host="MY_PROXY_HOST" proxy_port="MY_PROXY_IP" locked="true"/>
    </transportSender>

So if you want only to use the proxy for particular clients, you can use the former approach. But if you want to use the proxy for all the clients in your system just use the later approach so you don’t need to edit each client.

This entry was posted in axis2/c, Tutorial/Guide, web services, wsf/php, wso2 and tagged , , , , , . Bookmark the permalink.

5 Responses to Invoking WSF/PHP Web Services Through Proxy

  1. Mike Palmer says:

    Just what I needed – Thanks!

  2. hidenprotect says:

    Thats really nice, may i post ur link into my blog ?

  3. dimuthu says:

    Sure, No problem.

    Dimuthu

  4. Do both Options exist in WSDL mode. Ive tried these and only amending the axis2.xml file seems to work

  5. dimuthu says:

    Yes. both options should be working. What is the release you are working on?

Leave a Reply

Your email address will not be published. Required fields are marked *