0

大家好!我尝试做 DHL Express,但我对 DHL 非常感兴趣,并不想提供帮助。所以我想寻求帮助。而且由于我没有得到任何只是底层 XML 的跟踪号码,所以我想寻求帮助。非常感谢你帮助我。我尝试什么:

// The url of the service 
$url = 'https://wsbexpress.dhl.com:443/sndpt/expressRateBook?WSDL';
// the soap operation which is called
$action = 'createShipmentRequest';

// the xml input of the service
$xmlrequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rat="http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/RateMsgRequest">

    <soapenv:Header>

     <wsse:Security soapenv:mustunderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken wsu:id="UsernameToken-5" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">   
            <wsse:Username>*********</wsse:Username>           
            <wsse:Password type="PasswordText">*******</wsse:Password>
            <wsse:Nonce encodingtype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">eUYebYfsjztETJ4Urt8AJw==</wsse:Nonce>
            <wsu:Created>' . date('Y-m-d H:i:s') . '</wsu:Created>
         </wsse:UsernameToken>
      </wsse:Security>

   <soapenv:Header/>
   <soapenv:Body>
     <rat:RateRequest>
    <RequestedShipment>
    <DropOffType>REGULAR_PICKUP</DropOffType>
          <Account>407194546</Account>
            <Currency>EUR</Currency>
          <UnitOfMeasurement>SI</UnitOfMeasurement>
         <Ship>
            <Shipper>
                <StreetLines>Street number 22</StreetLines>
                <City>City</City>             
                <PostalCode>111111</PostalCode>
                <CountryCode>DE</CountryCode>
            </Shipper>
            <Recipient>
                <StreetLines>Street number 22</StreetLines>
                <City>City</City>             
                <PostalCode>111111</PostalCode>
                <CountryCode>DE</CountryCode>
            </Recipient>
        </Ship>
        <Packages>
            <RequestedPackages number="1">
                <Weight>
                    <Value>0.5</Value>
                </Weight>
                <Dimensions>
                    <Length>3</Length>
                    <Width>2</Width>
                    <Height>1</Height>
                </Dimensions>
            </RequestedPackages>
        </Packages>
        <ShipTimestamp>2018-07-18T08:00:00 GMT+0100</ShipTimestamp>
         <Content>NON_DOCUMENTS</Content>
        <PaymentInfo>DAP</PaymentInfo>      
    </RequestedShipment>
      </rat:RateRequest>
   </soapenv:Body>
</soapenv:Envelope>';

try {

    // the soap client accepts options, we specify the soap version
    // The trace option enables tracing of request so faults can be backtraced.
    // The exceptions option is a boolean value defining whether soap errors throw exceptions of type SoapFault. 
    $opts = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    );
    $options = array(
        'encoding' => 'UTF-8',
        'verifypeer' => false,
        'verifyhost' => false,
        'soap_version' => SOAP_1_2,
        'trace' => 1,
        'exceptions' => 1,
        'connection_timeout' => 180,
        'stream_context' => stream_context_create($opts),
        'cache_wsdl' => WSDL_CACHE_NONE,
    );

    // create the soapclient and invoke __doRequest method
    $client = new SoapClient($url, $options);
    $output = $client->__doRequest($xmlrequest, $url, $action, 1);
} catch (SoapFault $fault) {
    echo "<h2>SOAP Fault!</h2><p>";
    echo "FaultCode: {$fault->faultcode} <br/>";
    echo "FaultString: {$fault->faultstring} <br/>";
    echo"</p/>";
}

echo "<h2>WSDL URL: </h2><p>";
echo $url;
echo "</p/>";

echo "<h2>Action: </h2><p>";
echo $action;
echo "</p/>";

echo "<h2>XMLRequest: </h2><p>";
echo $xmlrequest;
echo "</p/>";

if (!isset($output)) {
    echo "<h2>SOAP Fault!</h2><p>";
    echo "FaultCode: {$output->faultcode} <br/>";
    echo "FaultString: {$output->faultstring} <br/>";
} else {
    echo "<h2>Output: </h2><p>";
    file_put_contents('dhl.xml', $output);
    echo $output;
    echo "</p/>";
}

返回:https ://justpaste.it/52zqa (抱歉太长了)

问题是我如何得到这个 xml?不返回货号并返回相应数据

4

1 回答 1

0

我认为您正在获取 WSDL,因为您的 URL 要求它。尝试删除?WSDL

$url = 'https://wsbexpress.dhl.com:443/sndpt/expressRateBook';

参考资料

于 2019-02-05T12:24:37.427 回答