duanli4146 2016-06-29 11:51
浏览 395

带代理的PHP SoapClient:如何通过代理访问模式?

When initializing the SoapClient class with proxy-options, the WSDL and its methods are accessed over proxy correctly:

$client = new SoapClient(
    WSDL_URL, 
    array(
        'proxy_host'     => PROXY_HOST,
        'proxy_port'     => PROXY_PORT
    )
);

Schemas (schemaLocation) however are not getting accessed over the specified proxy:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified">
    <xs:import namespace="http://example.com/webservice/cisbase" schemaLocation="http://example.com/ws/cis_base.xsd"/>
    <xs:import namespace="http://de.ws.example" schemaLocation="http://example.com/ws/is_base_de.xsd"/>
</xs:schema>

This leads to:

SOAP-ERROR: Parsing Schema: can't import schema from ...

So basically the SoapClient is trying to access the cis_base.xsd and is_base_de.xsd without proxy which is failing.

Is there a reason why the PHP SoapClient behaves like this and is there a workaround?

  • 写回答

2条回答 默认 最新

  • dongxun8189 2016-06-30 14:14
    关注

    In my code i use those options and that works great with our proxy and https protocol. I hope that will work for you to :)

            'proxy_host' => PROXY_HOST, 
            'proxy_port' => PROXY_PORT,
            'stream_context' => stream_context_create(
                array(
                    'ssl' => array(
                        'verify_peer'       => false,
                        'verify_peer_name'  => false,
                    )
                )
            )
    

    Regards.

    评论

报告相同问题?