我必须连接到 Web 服务并调用函数,但始终显示此错误:
Web 服务具有以下 WSDL:https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx?WSDL
错误:
SOAPFault:服务器无法处理请求。 ---> 对象引用未设置为对象的实例。
我不是这方面的专家,但该函数需要一个 xml,我像这样传递:
<distDFeInt xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00">
<tpAmb>1</tpAmb>
<cUFAutor>35</cUFAutor>
<CNPJ>12345678912345</CNPJ>
<distNSU>
<ultNSU>000000000000000</ultNSU>
</distNSU>
</distDFeInt>
这是我的代码:
$context = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
`enter code here`'allow_self_signed' => true
]
];
$context = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
$params = [
'local_cert' => $path_certificado,
'passphrase'=> '123456',
'uri' => 'http://www.portalfiscal.inf.br/nfe', // target namespace
'location' => 'https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx', // is the URL of the remote Web service
'cache_wsdl' => WSDL_CACHE_NONE,
'soapaction' => 'http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse',
'stream_context' => stream_context_create($context),
'use' => SOAP_LITERAL
];
try {
$client = new SoapClient(null, $params);
$xml = self::createXml();
$client->__soapCall('nfeDistDFeInteresse', [$xml], ['soapaction' => 'http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse', 'Host' => 'www1.nfe.fazenda.gov.br', 'Content-Type' => ' text/xml; charset=utf-8', 'Content-Length' => 'length']);
return $client;
} catch (SoapFault $e) {
echo $e;
}
wsdl:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe">
<s:element name="nfeDistDFeInteresse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="nfeDadosMsg">
<s:complexType mixed="true">
<s:sequence>
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="nfeDistDFeInteresseResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="nfeDistDFeInteresseResult">
<s:complexType mixed="true">
<s:sequence>
<s:any />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="nfeDistDFeInteresseSoapIn">
<wsdl:part name="parameters" element="tns:nfeDistDFeInteresse" />
</wsdl:message>
<wsdl:message name="nfeDistDFeInteresseSoapOut">
<wsdl:part name="parameters" element="tns:nfeDistDFeInteresseResponse" />
</wsdl:message>
<wsdl:portType name="NFeDistribuicaoDFeSoap">
<wsdl:operation name="nfeDistDFeInteresse">
<wsdl:input message="tns:nfeDistDFeInteresseSoapIn" />
<wsdl:output message="tns:nfeDistDFeInteresseSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NFeDistribuicaoDFeSoap" type="tns:NFeDistribuicaoDFeSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="nfeDistDFeInteresse">
<soap:operation soapAction="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="NFeDistribuicaoDFeSoap12" type="tns:NFeDistribuicaoDFeSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="nfeDistDFeInteresse">
<soap12:operation soapAction="http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NFeDistribuicaoDFe">
<wsdl:port name="NFeDistribuicaoDFeSoap" binding="tns:NFeDistribuicaoDFeSoap">
<soap:address location="https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx" />
</wsdl:port>
<wsdl:port name="NFeDistribuicaoDFeSoap12" binding="tns:NFeDistribuicaoDFeSoap12">
<soap12:address location="https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我做错了什么?谢谢的
这对我有用:
$result = $client->nfeDistDFeInteresse(['nfeDadosMsg' => new SoapVar($xml, SOAP_ENCODED)]);