mheavers
mheavers

Reputation: 30158

php - how to make a proxy for a web service

I'm trying to get around an access control origin error for a web service by building a local proxy, but I'm not sure how to do it. The web service looks like the attached file, and is accessed directly by using the following URL:

https://url.com/SparkService.asmx?op=InsertConsumer

How would I write something locally that carried out this URL's functionality?

I built a PHP file that will pull the web service URLs contents, but it doesn't seem to carry out the functionality of that web service:

<?php
    $op = htmlspecialchars($_GET["op"]);
    $proxyURL = 'https://url.com/SparkService.asmx?op=' . $op;
    die( file_get_contents($proxyURL) );
?>

enter image description here

Upvotes: 0

Views: 1891

Answers (2)

Amila Suriarachchi
Amila Suriarachchi

Reputation: 1238

I am not sure about your intension of doing this.

you can use WSO2 ESB proxy[1] to send messages to the real service through a local end point. Or else you can create your own service by using WSO2 AS[2] and deploying a sample POJO as a web service.

[1] http://wso2.org/project/esb/java/4.0.0/docs/samples/proxy_samples.html [2] http://wso2.org/project/app-server/

Upvotes: 0

Marc B
Marc B

Reputation: 360662

The image shows you have to use a POST, which you can't do with bare-bones file_get_contents - it defaults to using a GET query. You'll have to use CURL, or set up a stream to configure and perform a POST.

Upvotes: 2

Related Questions