duanji1899 2018-10-17 02:24
浏览 98

将XML请求发送到SOAP Web服务

I am trying to send a XML request to a webservice of a government agency and I am getting the following error:

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 
)

The same XML in SoapUI is returning the actual response.

WSDL is here: https://www.gateway.uat.asic.gov.au/gateway/ExternalSearchNniNamePortV3?wsdl

This is my PHP code:

<?
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());

        }
    }
}

What am I doing wrong? I am running this from within Wordpress.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?