将XML请求发送到SOAP网络服务

时间:2018-10-17 02:24:09

标签: php xml web-services soap soap-client

我正在尝试将XML请求发送到政府机构的Web服务,但出现以下错误:

Array ( 
    [file] => /Applications/AMPPS/www/wordpress/wp-blog-header.php 
    [line] => 13 
    [args] => Array ( 
        [0] => /Applications/AMPPS/www/wordpress/wp-load.php 
    ) 
    [function] => require_once 
) 
[10] => Array ( 
    [file] => /Applications/AMPPS/www/wordpress/index.php 
    [line] => 17 
    [args] => Array ( 
        [0] => /Applications/AMPPS/www/wordpress/wp-blog-header.php 
    ) 
    [function] => require 
) ) 
[previous:Exception:private] => 
    [faultstring] => Internal Error 
    [faultcode] => env:Client 
)

SoapUI中的相同XML返回实际响应。

WSDL在这里:https://www.gateway.uat.asic.gov.au/gateway/ExternalSearchNniNamePortV3?wsdl

这是我的PHP代码:

<?
function wbcr_cheeco_biz_name_action()
{
    if (isset($_GET['wbcr_cheeco_biz_name_action'])) {
        $wsdl = "https://www.gateway.uat.asic.gov.au/gateway/ExternalSearchNniNamePortV3?wsdl";

        $soapClientOptions = array(

            'trace' => 1,
            'soap_version' => SOAP_1_1,
            'encoding' => 'UTF-8',
            'uri' => 'uri:v3.external.search.nni.name.asic.gov.au',
            'exceptions' => false,
            'login' => '*',
            'password' => '*',
            'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
            'use' => SOAP_LITERAL,
            'style' => SOAP_DOCUMENT,
            'stream_context' => stream_context_create(array(
                'ssl' => array(
                    'verify_peer' => false,
                    'verify_peer_name' => false,
                    'allow_self_signed' => true,
                ),
            )),
        );
        $client = new SoapClient($wsdl, $soapClientOptions);
        $client->__setLocation('https://www.gateway.uat.asic.gov.au/gateway/ExternalSearchNniNamePortV3');

        try {

            $body = '<uri:request xmlns:uri="uri:v3.external.search.nni.name.asic.gov.au"
                      xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
                      xmlns:uri1="uri:business.document.header.types.asic.gov.au" xmlns:uri2="uri:fss.types.asic.gov.au"
                      xmlns:uri3="uri:types.asic.gov.au" xmlns:uri4="uri:nni.types.asic.gov.au"
                      oas:Id="Example-1">
                     <uri1:businessDocumentHeader>
                        <uri1:messageType>S</uri1:messageType>
                        <uri1:messageReferenceNumber>121221</uri1:messageReferenceNumber>
                        <uri1:messageVersion>3</uri1:messageVersion>
                        <uri1:senderId>S00202</uri1:senderId>
                        <uri1:senderType>REGA</uri1:senderType>
                     </uri1:businessDocumentHeader>
                     <uri:businessDocumentBody>
                        <uri4:searchType>S</uri4:searchType>
                        <uri4:searchScope>A</uri4:searchScope>
                        <uri4:organisation>
                           <uri4:name>CALEIDRO</uri4:name>
                        </uri4:organisation>
                        <uri4:maxResult>1</uri4:maxResult>
                     </uri:businessDocumentBody>
                  </uri:request>';

            $soapBody = new SoapVar($body, XSD_ANYXML);

            $response_param = $client->externalSearchNniName($soapBody);

            exit('My response is ' . print_r($response_param));
        } catch (Exception $e) {

            exit('ERROR ' . $e->getMessage() . ' ================= ' . $client->__getLastRequest());

        }
    }
}

我在做什么错?我正在Wordpress中运行它。

0 个答案:

没有答案