2014-12-30 2 views
0

비누로 서버에 로그인하고 토큰을 다시 가져옵니다. 문제가 없습니다 ....PHP가 헤더 정보를 수정하지 않습니다.

다음 토큰을 soap : 헤더에 추가하십시오.

이것은 내가 작성하려고하는 것입니다.

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Header> 
    <WSAuthorization xmlns="http://url.com/testing/"> 
     <Token>string</Token> 
    </WSAuthorization> 
    </soap12:Header> 
    <soap12:Body> 
    <ImportDrugTest xmlns="http://url.com/testing/"> 
     <specimenID>int</specimenID> 
     <midasNumber>string</midasNumber> 
     <specimenComments>string</specimenComments> 
     <nonRXDrugsUsed>string</nonRXDrugsUsed> 
     <testCode>string</testCode> 
     <testDate>dateTime</testDate> 
     <testResult>string</testResult> 
     <collectionDate>dateTime</collectionDate> 
     <lastName>string</lastName> 
     <firstName>string</firstName> 
     <middleName>string</middleName> 
     <CRUDFlag>string</CRUDFlag> 
    </ImportDrugTest> 
    </soap12:Body> 
</soap12:Envelope> 

이 내가 여기

<?xml version="1.0" encoding="UTF-8"?> 
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://url.com/testing/"> 
    <soap-env:header> 
     <ns1:wsauthorization /> 
    </soap-env:header> 
    <soap-env:body> 
     <ns1:importdrugtest> 
      <ns1:specimenid>605431024</ns1:specimenid> 
      <ns1:midasnumber>7700MD2005000001.00</ns1:midasnumber> 
      <ns1:specimencomments>Miscellaneous</ns1:specimencomments> 
      <ns1:nonrxdrugsused>N/A</ns1:nonrxdrugsused> 
      <ns1:testcode>025000</ns1:testcode> 
      <ns1:testdate>2012-09-24</ns1:testdate> 
      <ns1:testresult>Negative</ns1:testresult> 
      <ns1:collectiondate>2012-09-25</ns1:collectiondate> 
      <ns1:lastname>Last</ns1:lastname> 
      <ns1:firstname>First</ns1:firstname> 
      <ns1:middlename>Middle</ns1:middlename> 
      <ns1:crudflag>C</ns1:crudflag> 
     </ns1:importdrugtest> 
    </soap-env:body> 
</soap-env:envelope> 

를 받고 내 코드입니다 것입니다. 참고 : 나는 이미 새로운 SoapClient()를 봤고 토큰을 위임했다.

$ns = 'http://url.com/testing/'; 
// $headerParams = array('WSAuthorization'=>array('token'=>$token)); tried this also 
$headerParams = array('token'=>$token); 
$header = new SoapHeader($ns, 'WSAuthorization', $headerParams);  

$client->__setSoapHeaders($header); 

$param = array('ImportTest' => array( 
       'specimenID' => '0605431024', 
       'midasNumber' => '7700MD2005000001.00', 
       'county' => '03', 
       'site' => '00', 
       'specimenComments' => 'Miscellaneous', 
       'nonRXDrugsUsed' => 'N/A', 
       'testCode' => '025000', 
       'testDate' => '2012-09-24', 
       'testResult' => 'Negative', 
       'collectionDate' => '2012-09-25', 
       'lastName' => 'Last', 
       'firstName' => 'First', 
       'middleName' => 'Middle', 
       'CRUDFlag' => 'C' 
      )); 

$result = $client->__soapCall('ImportDrugTest', $param); 

업데이트 12/31/14 :

나는 코드를 수정 ($ 헤더) 인 print_r을 추가 :

SoapHeader Object 
(
    [namespace] => http://url.com/testing/ 
    [name] => WSAuthorization 
    [data] => Array 
     (
      [token] => UDjVSzGt9J4fKuRuoFHau3gy4CoLo//VlnuZv5oy5tjKPffIeSc+dx7EEDIfosVkVHDD0G/ZBANnCzPmRBo6CIusRL5rak5QdYI9jD7209c= 
     ) 

    [mustUnderstand] => 
) 

:이 얻을

$ns = "http://url.com/testing/"; 
$headerParams = array('token'=>$token); 
$header = new SoapHeader($ns, 'WSAuthorization', $headerParams);  
print_r($header); 
$client->__setSoapHeaders(array($header)); // even tried $client->__setSoapHeaders($header); 

그러나 __getLastRequest()는 다음과 같이 나타냅니다.

<soap-env:header> 
    <ns1:wsauthorization /> 
</soap-env:header> 

무엇이 누락 되었습니까?

+0

헤더 및 http://php.net/manual/en/soapheader.soapheader.php –

+0

에 대한 문서 및 의견을 확인합니다. 설명서를 확인했습니다. _soapCall ('ImportDrugTest', $ param, null, $ header)에 헤더를 추가하려고 시도했습니다. – todd

답변

0

이 작동 : 내가 가졌다

$headerParams = array('Token' => $token); 
$header  = new SoapHeader($NameSpace, 'WSAuthorization', $headerParams, false); 

문제는 응답에서 구문 분석되지 않는 토큰에 의해 발생했다.

관련 문제