实在是没办法了,来这请教做过 soap 的 phper

2017-03-20 17:19:15 +08:00
 zhangjw152
利用 soapui 可以拿到接口数据,但是用 php 请求没反应,关键是 server 端那边只能查看成功的请求不能看我发送过去的东西。。。。
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);
}
}
1353 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/348891

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX