2013-10-08 3 views
1

내가 -this wsdl-에 설명 된 방법 GeneraTimbre를 소비하기 위해 노력하고있어 [SOLVED] :PHP의 SOAP 요청

$timbrador=new SoapClient("http://test.timbrado.com.mx/cfdi/wsTimbrado.asmx?wsdl"); 
$header = array('UserName' => $user,'Password' => $pass); 
$Soapheader = new SOAPHeader('https://test.timbrado.com.mx/cfdi/', 'AuthenticationHeader', $header); 
$timbrador->__setSoapHeaders($Soapheader); 
$xml="An Xml String...."; 
$cfdi=$timbrador->GeneraTimbre(base64_encode($xml)); 

이 :

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="https://test.timbrado.com.mx/cfdi/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="https://test.timbrado.com.mx/cfdi/"> 
<wsdl:types> 
<s:schema elementFormDefault="qualified" targetNamespace="https://test.timbrado.com.mx/cfdi/"> 
<s:element name="GeneraTimbre"> 
<s:complexType> 
<s:sequence> 
<s:element minOccurs="0" maxOccurs="1" name="xmlBytes" type="s:base64Binary"/> 
</s:sequence> 
</s:complexType> 
</s:element> 
<s:element name="GeneraTimbreResponse"> 
<s:complexType> 
<s:sequence> 
<s:element minOccurs="0" maxOccurs="1" name="GeneraTimbreResult" type="s:string"/> 
</s:sequence> 
</s:complexType> 
</s:element> 
<s:element name="AuthenticationHeader" type="tns:AuthenticationHeader"/> 
<s:complexType name="AuthenticationHeader"> 
<s:sequence> 
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string"/> 
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/> 
</s:sequence> 
<s:anyAttribute/>... 

내 코드는 다음과 같이 간다 __getLastRequest()에 대한 요청입니다.

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://test.timbrado.com.mx/cfdi/"> 
    <SOAP-ENV:Header><ns1:AuthenticationHeader><ns1:UserName>0000000001</ns1:UserName><ns1:Password>pwd</ns1:Password></ns1:AuthenticationHeader></SOAP-ENV:Header> 
     <SOAP-ENV:Body><ns1:GeneraTimbre/></SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 
내가 ii'm 내가 인코딩 줄에서 함수에 전송되는 데이터가 표시되지 않기 때문에 그것의 생각, 서버에서 "빈 버퍼"응답을 수신하고있어

:

base64_encode($xml); (if i echo it, i get a long string like this: 

PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4gDQo8Y2ZkaTpDb21wcm9iYW50ZSB4bWxuczpjZmRpPSJodHRwOi8vd3d3LnNhdC5nb2IubXgvY2ZkLzMiIHhtb .. ..)

SOAP에 익숙하지 않아서 문자열이 요청 어딘가에 있어야한다고 생각하니 괜찮습니까? 아니면 내가 코드에서 뭔가 잘못하고 있는거야?.

------------------------- 솔루션 ------------------ ----

그래서 내가 담당하는 사람을 접촉하고 "무엇을 당신이 당신의 WS에서 얻을 기대"물었고, 나는

public function timbrar($xml)//receives the xml string to be sent 
    { 
     $request='<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:cfdi="https://test.timbrado.com.mx/cfdi/"> 
    <soap:Header> 
     <cfdi:AuthenticationHeader> 
<cfdi:UserName>0000000001</cfdi:UserName> 
      <cfdi:Password>pwd</cfdi:Password> 
     </cfdi:AuthenticationHeader> 
    </soap:Header> 
    <soap:Body> 
     <cfdi:GeneraTimbre> 
<cfdi:xmlBytes>'.base64_encode($xml).'</cfdi:xmlBytes> 
     </cfdi:GeneraTimbre> 
    </soap:Body> 
</soap:Envelope>'; 
     try 
     { 
     $cfdi=$this->timbrador-> 
     __doRequest($request,"http://test.timbrado.com.mx/cfdi/wsTimbrado.asmx", 
     "http://test.timbrado.com.mx/cfdi/wsTimbrado.asmx?op=GeneraTimbre", 
     SOAP_1_2, 
     0); 
     $this->resultado_timbre=$cfdi; 
     }catch(SoapFault $fault){ 
      echo "REQUEST:<br>" . htmlentities(str_ireplace('><', ">\n<", $this->timbrador->__getLastRequest())) . "<br>"; 
      echo "Response:<br>" . htmlentities(str_ireplace('><', ">\n<", $this->timbrador->__getLastResponse())) . "<br>"; 
     $fault->getMessage(); 
} 
    } 
(클래스라고 timbrador에서)이 기능으로 문제를 해결
+0

안녕하세요, 'CancelaCFDIs'웹 서비스 코드가 있습니까 ?? – AgelessEssence

답변

0

이 시도 :

$params = array('xmlBytes'=>base64_encode(file_get_contents($xml))); 
$result = $client->GeneraTimbre($params); 

SOAP에 익숙하지 않아 동일한 WS에서 작동하지만 아직 성공하지 못했습니다.

+0

고마워, 나는 그것을 시도하고 무슨 일이 일어날 지 알려주지 –

+0

해결! 솔루션이 당신을 도울 수 있기를 바랍니다. –