php - how to make a proxy for a web service

2019-09-03 04:44发布

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

2条回答
爷的心禁止访问
2楼-- · 2019-09-03 05:22

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/

查看更多
混吃等死
3楼-- · 2019-09-03 05:27

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.

查看更多
登录 后发表回答