V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
zhangjw152
V2EX  ›  问与答

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

  •  
  •   zhangjw152 · 2017-03-20 17:19:15 +08:00 · 1349 次点击
    这是一个创建于 2834 天前的主题,其中的信息可能已经有所发展或是发生改变。
    利用 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);
    }
    }
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5510 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:58 · PVG 13:58 · LAX 21:58 · JFK 00:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.