繁体   English   中英

php curl soap 错误,<faultcode> soap:客户端</faultcode>无法处理没有有效操作参数的请求。 请提供有效的 soap action.r

[英]php curl soap error, <faultcode>soap:Client</faultcode> Unable to handle request without a valid action parameter. Please supply a valid soap action.r

I am trying to access the soap webservice via curl in php but i am receiving the error message like soap:Client Unable to handle request without a valid action parameter. 请提供有效的 soap 操作。

我也尝试了 SOAPUI 和 Postman 但它们也出现了相同的错误。

SOAP XML:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
<Document-Invoice>
  <Invoice-Header>
    <InvoiceNumber>BIZ2020000000304</InvoiceNumber>
    <InvoiceDate>2020-05-30</InvoiceDate>
    <DocumentFunctionCode>O</DocumentFunctionCode>
    <InvoiceProfile>BI</InvoiceProfile>
    <MessageType>S</MessageType>
    <Remarks>PO: P2320734</Remarks>
    <Order>
      <BuyerOrderNumber>P2320734</BuyerOrderNumber>
      <BuyerOrderDate>2020-05-30</BuyerOrderDate>
    </Order>
    <Currency>
      <InvoiceCurrency>TRL</InvoiceCurrency>
    </Currency>
    <Payment>
      <PaymentMeans>42</PaymentMeans>
    </Payment>
  </Invoice-Header>
  <Invoice-Parties>
    <Buyer>
      <ILN>9990000001049</ILN>
      <TaxID>4840031463</TaxID>
      <IDType>VKN</IDType>
      <Name>Johnson and Johnson Sıhhi Malzeme San. Ve Tic. Ltd. Şti</Name>
      <StreetName>Ertürk Sok  Kavacık</StreetName>
      <BuildingNumber>No:13</BuildingNumber>
      <BuildingName>Keçeli Pl.</BuildingName>
      <District>Beykoz</District>
      <CityName>İstanbul</CityName>
      <CountryName>Türkiye</CountryName>
      <Country>TR</Country>
      <TaxOfficeName>Büyük Mükellefler</TaxOfficeName>
      <PhoneNumber>0216 538 20 00</PhoneNumber>
      <Fax>0216 538 22 99</Fax>
    </Buyer>
    <Seller>
      <ILN>9996440256367</ILN>
      <TaxID>6440256367</TaxID>
      <IDType>VKN</IDType>
      <Name>Bizofis Bilgi Teknolojileri ve Yönetim Danışmanlık Hizmetleri Ticaret Limited Şirketi</Name>
      <Room>6</Room>
      <StreetName>Matbuat Sok.</StreetName>
      <BuildingNumber>17</BuildingNumber>
      <BuildingName>Durukan İş Merkezi</BuildingName>
      <District>ŞİŞLİ</District>
      <CityName>İSTANBUL</CityName>
      <PostalCode>34394</PostalCode>
      <CountryName>TÜRKİYE</CountryName>
      <Country>TR</Country>
      <TaxOfficeName>Zincirlikuyu</TaxOfficeName>
      <PhoneNumber>0212 212 18 98</PhoneNumber>
      <Fax>0212 356 39 99</Fax>
      <Website>www.bizofis.com</Website>
      <AdditionalIdentification>
        <Identification>
          <Type>TICARETSICILNO</Type>
          <Value>499957</Value>
        </Identification>
        <Identification>
          <Type>MERSISNO</Type>
          <Value>0-6440-2563-6700014</Value>
        </Identification>
      </AdditionalIdentification>
    </Seller>
  </Invoice-Parties>
  <Invoice-Lines>
    <Line>
      <Line-Item>
        <LineNumber>1</LineNumber>
        <ManufacturerItemCode>9990000000008</ManufacturerItemCode>
        <ItemName>Hizmet Bedeli </ItemName>
        <InvoiceQuantity>1.000</InvoiceQuantity>
        <UnitOfMeasure>NIU</UnitOfMeasure>
        <InvoiceUnitNetPrice>1286.3500</InvoiceUnitNetPrice>
        <NetAmount>1286.35</NetAmount>
        <TaxAmount>231.54</TaxAmount>
      </Line-Item>
      <Line-Tax>
        <Tax>
          <TaxRate>18.00</TaxRate>
          <TaxCategoryCode>0015</TaxCategoryCode>
          <TaxCategory>KDV GERCEK</TaxCategory>
          <TaxAmount>231.54</TaxAmount>
          <TaxableAmount>1286.35</TaxableAmount>
        </Tax>
      </Line-Tax>
    </Line>
  </Invoice-Lines>
  <Invoice-Summary>
    <TotalLines>1</TotalLines>
    <TotalNetAmount>1286.35</TotalNetAmount>
    <TotalTaxableAmount>1286.35</TotalTaxableAmount>
    <TotalTaxAmount>231.54</TotalTaxAmount>
    <TotalGrossAmount>1517.89</TotalGrossAmount>
    <TotalAllowanceAmount>0.00</TotalAllowanceAmount>
    <TotalChargeAmount>0.00</TotalChargeAmount>
    <TotalPayableAmount>1517.89</TotalPayableAmount>
    <Tax-Summary>
      <Tax-Summary-Line>
        <TaxRate>18.00</TaxRate>
        <TaxCategoryCode>0015</TaxCategoryCode>
        <TaxCategory>KDV GERCEK</TaxCategory>
        <TaxAmount>231.54</TaxAmount>
        <TaxableAmount>1286.35</TaxableAmount>
      </Tax-Summary-Line>
    </Tax-Summary>
  </Invoice-Summary>
</Document-Invoice>
</soap:Body>
</soap:Envelope>

Curl 代码

$url = 'https://www.ecod.pl/EcodWebService/EDIservice.asmx';

                $CURL = curl_init();

                curl_setopt($CURL, CURLOPT_URL, $url);
                curl_setopt($CURL, CURLOPT_POST,true); 
                curl_setopt($CURL, CURLOPT_POSTFIELDS, $xml_string); 
                curl_setopt($CURL, CURLOPT_HEADER, 1); 
                curl_setopt($CURL, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($CURL, CURLOPT_SSL_VERIFYHOST, false);
                curl_setopt($CURL, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($CURL, curlOPT_VERBOSE, 1);

                $headers = array(
                    "Content-type: text/xml; charset=utf-8",
                    "Accept: text/xml", 
                    'Content-Length: '.strlen($xml_string) 
                ); 

                curl_setopt($CURL, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($CURL, CURLOPT_USERPWD, $username . ":" . $password);

                $xmlResponse = curl_exec($CURL); 

                $curlInfo = curl_getinfo($CURL, CURLINFO_HTTP_CODE);
                // $curlInfo= curl_getinfo($CURL);

                $errors = curl_error($CURL);

                print_r($xmlResponse);
                echo 'info=';print_r($curlInfo);
                echo 'error=';print_r($errors);exit;

任何人都可以帮助我。 谢谢

使用 SoapClient 只需要几行代码……但是,有几种方法可以配置某些东西,例如 HTTPS、代理使用、缓存、超时……

// ToDo: Put in URL to WSDL
$live_wsdl = "..."; 
$params = [
    'soap_version' => SOAP_1_2, 
    'encoding' => 'UTF-8',
]; 

$soap = new SoapClient($live_wsdl, $params); 

try {
    echo '<pre>';
    var_dump($soap);
    $funcs = $soap->__getFunctions();
    $types = $soap->__getTypes();

    print_r($funcs);
}
catch(Exception $e) {
    var_dump($e);
}

基本上,你可以直接调用暴露的 API 函数: $soap->DoSomeAction($param1, $param2, ...);

希望它有点帮助...

高频

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM