PHP |通过soap发送数据集


php | send dataset via soap

嗨,我需要创建一个通过php soap请求发送这些数据的请求。什么是正确的格式?

        <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <GetVouTrans xmlns="http://tempuri.org/">
          <VoucherRequest>
            <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
              <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
                <xs:complexType>
                  <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element name="kritiria">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="type" type="xs:short" minOccurs="0" />
                          <xs:element name="voucher" type="xs:string" minOccurs="0" />
                          <xs:element name="customer" type="xs:string" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:choice>
                </xs:complexType>
              </xs:element>
            </xs:schema>
            <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
              <NewDataSet xmlns="">
                <kritiria diffgr:id="kritiria1" msdata:rowOrder="0">
                  <type>0</type>
                  <voucher>012345678</voucher>
                  <customer>pexpor213</customer>
                </kritiria>
              </NewDataSet>
            </diffgr:diffgram>
          </VoucherRequest>
        </GetVouTrans>
      </soap:Body>
    </soap:Envelope>

我如何发送一个数据集通过soap与php?

我发送请求,但它响应我错误。它认为我没有以正确的方式发送数据集值:

            $faulty = 'Fault method';
            $wsdl = "http://www.speedex.gr/getvoutrans/GetVouTrans.asmx?WSDL";      
            $soapClient = new SoapClient($wsdl,
                    array(
                        'trace' => true,
                        'use' => SOAP_LITERAL,
                        'style' => SOAP_DOCUMENT,
                    )
                );  
            $parm = array();
            $parm[] = new SoapVar('0', XSD_SHORT, null, null, 'type' );
            $parm[] = new SoapVar('010658696378', XSD_STRING, null, null, 'voucher' );
            $parm[] = new SoapVar('ΠΕ145031', XSD_STRING, null, null, 'customer' );
            try {
                $resp = $soapClient->GetVouTrans( new SoapVar($parm, SOAP_ENC_OBJECT) );
                print_r ("REQUEST:'n" . htmlentities($soapClient->__getLastRequest()) . "'n");
                print_r ("RESPONSE:'n" . htmlentities($soapClient->__getLastResponse()) . "'n");    
            } catch (SoapFault $e) {
                echo $faulty;
                return false;
            }

正确的方法是使用库。所有内容都写在这里http://php.net/manual/en/book.soap.php

编辑:


我对此进行了一些研究(我不是SOAP专家,因为我不经常使用它,也不喜欢它)。但是,您使用的wsdl文件没有指定您使用的任何参数。实际上你应该能够使用call:

$soapClient->GetVouTrans(0, '010658696378', 'ΠΕ145031' );
// order is important, as WSDL states it. But it doesn't so this call for this web service is not valid.

下一个,从未见过文档,在这里找到了一些:http://www.speedex.gr/getvoutrans/getvoutrans.asmx?op=GetVouTrans
第一个奇怪的事情是,这个文档没有说明任何关于你传递的参数。

实际上,对我来说奇怪的是示例请求。

<soap12:calledMethodName>
// I only seen
<ns1:calledMethodName>

我没有找到任何方法来改变它(也许你需要你自己的SOAP客户端*)。

关于这个api的下一个奇怪的事情是:它永远不会返回(无论参数)不同的响应。没有错误/异常。

* -实际上,可能是的情况。他们自己编写了一些类似soap的实现。它与标准SOAP库不兼容。

你见过成功地实现某人与他们的API集成吗?

此外,发现类似的从未回答过问题:PHP Soap和。net数据集

结果可能是,这个API不工作或需要一些特定的实现