zhangjw152
zhangjw152
2017-03-20 07:05

利用soapui可以拿到接口数据,但是用php没反应

10
  • wsdl
  • soapui
  • php
  • api

下面是利用soapui连接时的头文件以及我的php连接程序,为什么会连接不上:
soapui请求文件:

 <soapenv:Envelope xmlns:hps="http://xmlns.oracle.com/Enterprise/Tools/schemas/HPSServiceDocs.HPSIncDataRequest.V1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-DD32B6F14FC8EDE72E148938979293413"><wsse:Username>*******</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">******</wsse:Password>
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">TU9w6K6cf1GQMMf/StK/zA==</wsse:Nonce>
                <wsu:Created>2017-03-13T07:23:12.934Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
    <soapenv:Body>
        <hps:HPSIncDataRequest>
            <hps:SYSTEM_ID>OA</hps:SYSTEM_ID>
            <hps:DATA_TYPE/>
            <hps:BGN_DT>2016-01-01 00:00:00</hps:BGN_DT>
            <hps:END_DT>2016-06-01 00:00:00</hps:END_DT>
            <hps:PAGE_NUM>1</hps:PAGE_NUM>
            <hps:PAGE_SIZE>1000</hps:PAGE_SIZE>
        </hps:HPSIncDataRequest>
    </soapenv:Body>
</soapenv:Envelope>

php代码:

 $wsdl = 'http://210.74.4.109:8888/PSIGW/PeopleSoftServiceListeningConnector/PSFT_HR/HPSSERVICE.1.wsdl';
$client = new SoapClient ($wsdl, array('style' => SOAP_DOCUMENT, 'trace' => 1, 'soap_version' => SOAP_1_1, 'exceptions' => false, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'ssl_method' => SOAP_SSL_METHOD_TLS));
$username = '*******';
$password = '******';
$created = date('Y-m-d\TH:i:s.0000\Z', time());
$prefix = gethostname();
$nonce = base64_encode(substr(md5(uniqid($prefix . '_', true)), 0, 16));
$header = '<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsse:UsernameToken wsu:Id="UsernameToken-45">
        <wsse:Username>' . $username . '</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' . $password . '</wsse:Password>
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' . $nonce . '</wsse:Nonce>
        <wsu:Created>' . $created . '</wsu:Created>
    </wsse:UsernameToken>
</wsse:Security>';
//        var_dump($header);
$request = array(
"HPSIncDataRequest" => array('SYSTEM_ID' => 'OA',
'DATA_TYPE' => '',
'BGN_DT' => '2016-01-01 00:00:00',
'END_DT' => '2016-06-01 00:00:00',
'PAGE_NUM' => 1,
'PAGE_SIZE' => 1000),
);
$headerSoapVar = new SoapVar($header, XSD_ANYXML);
//        var_dump($headerSoapVar);
$soapheader = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd', "Security", $headerSoapVar, true);
$client->__setSoapHeaders($soapheader);
$body = '<hps:HPSIncDataRequest>
    <hps:SYSTEM_ID>OA</hps:SYSTEM_ID>
    <hps:DATA_TYPE/>
    <hps:BGN_DT>2016-01-01 00:00:00</hps:BGN_DT>
    <hps:END_DT>2016-06-01 00:00:00</hps:END_DT>
    <hps:PAGE_NUM>1</hps:PAGE_NUM>
    <hps:PAGE_SIZE>1000</hps:PAGE_SIZE>
</hps:HPSIncDataRequest>';
$bodySoapVar = new SoapVar($body, XSD_ANYXML);
try {
//            $client->HPSJCODEINCDATASERVICE( $request);
$client->__soapCall('HPSJCODEINCDATASERVICE', $request);
echo "<br /><br />REQUEST:\n" . $client->__getLastRequest() . "<br /><br />";
echo "REQUEST HEADERS:\n" . $client->__getLastRequestHeaders() . "<br /><br />";
echo "RESPONSE:\n" . $client->__getLastResponse() . "<br /><br />";
echo "RESPONSE HEADERS:\n" . $client->__getLastResponseHeaders() . "<br /><br />";
echo "Var Dump: ";
} catch (SoapFault $soapFault) {
print_r($soapFault);
}
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换