Como criar uma solicitação SOAP PHP com vários namespaces

Estou tentando obter uma cotação de remessa de um serviço SOAP. Consegui criar com êxito cabeçalhos de autenticação e consultar o serviço SOAP com solicitações básicas que não exigem parâmetros de corp

Sou capaz de criar a estrutura adequada para a solicitação, mas os valores do espaço para nome não estão aparecendo na saída da solicitaçã

Exemplo do código:

$client = new SoapClient("http://demo.smc3.com/AdminManager/services/RateWareXL?wsdl",
                   array('trace' => TRUE));

$headerParams = array('ns1:licenseKey'    => $key,
                      'ns1:password'      => $pass,
                      'ns1:username'      => $user);

$soapStruct = new SoapVar($headerParams, SOAP_ENC_OBJECT);
$header = new SoapHeader($ns, 'AuthenticationToken', $soapStruct, false);
$client->__setSoapHeaders($header);

// Check if shipping is ready - base call
$ready_to_ship = $client->isReady();

Os itens acima funcionam perfeitamente e retornam true se o serviço de remessa estiver disponíve

Então, eu uso o código a seguir para criar o corpo da solicitação (preenchendo apenas os campos obrigatórios): Eu também tentei colocar tudo em uma matriz e convertê-la em um SoapVar, tentei incluir ns1: e ns2: na solicitação do corpo criação, mas isso também não funcionou. Acredito que algo precisa ser ajustado na criação da solicitação ... não tenho certeza da melhor abordagem ..

$rate_request = $client->LTLRateShipment;
$rate_request->LTLRateShipmentRequest->destinationCountry = $destination_country;
$rate_request->LTLRateShipmentRequest->destinationPostalCode = $destination_postal_code;
$rate_request->LTLRateShipmentRequest->destinationPostalCode = $destination_postal_code;
$rate_request->LTLRateShipmentRequest->details->LTLRequestDetail->nmfcClass = $ship_class;
$rate_request->LTLRateShipmentRequest->details->LTLRequestDetail->weight = $ship_weight;
$rate_request->LTLRateShipmentRequest->originCountry = $origin_country;
$rate_request->LTLRateShipmentRequest->originPostalCode = $origin_postal_code;
$rate_request->LTLRateShipmentRequest->shipmentDateCCYYMMDD = $ship_date; 
$rate_request->LTLRateShipmentRequest->tariffName = $tariff; 

E produz o seguinte XML:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservices.smc.com">
        <SOAP-ENV:Header>
            <ns1:AuthenticationToken>
                <ns1:licenseKey>xxxxxxxx</ns1:licenseKey>
                <ns1:password>xxxxxxxx</ns1:password>
                <ns1:username>xxxxxxxxm</ns1:username>
                    </ns1:AuthenticationToken>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:LTLRateShipment>
            <LTLRateShipmentRequest>
                <destinationCountry>USA</destinationCountry>
                <destinationPostalCode>10001</destinationPostalCode>
        <details>
              <LTLRequestDetail>
          <nmfcClass>60</nmfcClass>
          <weight>300</weight>
                          </LTLRequestDetail>
        </details> 
                          <originCountry>USA</originCountry>
                <originPostalCode>90210</originPostalCode>
                <shipmentDateCCYYMMDD>20110516</shipmentDateCCYYMMDD>
                <tariffName>DEMOLTLA</tariffName>
            </LTLRateShipmentRequest>
        </ns1:LTLRateShipment>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

Mas a saída deve incluir os espaços para nome (web: e web1: quando apropriado). A solicitação acima retorna um código de erro de tariffName ausent

Aqui está um exemplo de como deve ser a solicitação xml:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:web="http://webservices.smc.com" xmlns:web1="http://web.ltl.smc.com"> 
   <soapenv:Header> 
      <web:AuthenticationToken> 
         <web:licenseKey> string </web:licenseKey> 
         <web:password> string </web:password> 
         <web:username> string </web:username> 
      </web:AuthenticationToken> 
   </soapenv:Header> 
   <soapenv:Body> 
      <web:LTLRateShipment> 
         <web:LTLRateShipmentRequest> 
            <web1:LTL_Surcharge> string </web1:LTL_Surcharge> 
            <web1:TL_Surcharge> string </web1:TL_Surcharge> 
            <web1:destinationCity> string </web1:destinationCity> 
            <web1:destinationCountry> string </web1:destinationCountry> 
            <web1:destinationPostalCode> string </web1:destinationPostalCode> 
            <web1:destinationState> string </web1:destinationState> 
            <web1:details> 
               <!--Zero or more repetitions:--> 
               <web1:LTLRequestDetail> 
                  <web1:nmfcClass> string </web1:nmfcClass> 
                  <web1:weight> string </web1:weight> 
               </web1:LTLRequestDetail> 
            </web1:details> 
            <web1:discountApplication> string </web1:discountApplication> 
            <web1:mcDiscount> string </web1:mcDiscount> 
            <web1:orgDestToGateWayPointFlag> string </web1:orgDestToGateWayPointFlag> 
            <web1:originCity> string </web1:originCity> 
            <web1:originCountry> string </web1:originCountry> 
            <web1:originPostalCode> string </web1:originPostalCode> 
            <web1:originState> string </web1:originState> 
            <web1:rateAdjustmentFactor> string </web1:rateAdjustmentFactor> 
            <web1:shipmentDateCCYYMMDD> string </web1:shipmentDateCCYYMMDD> 
            <web1:shipmentID> string </web1:shipmentID> 
            <web1:stopAlternationWeight> string </web1:stopAlternationWeight> 
            <web1:surchargeApplication> string </web1:surchargeApplication> 
            <web1:tariffName> string </web1:tariffName> 
            <web1:weightBreak_Discount_1> string </web1:weightBreak_Discount_1> 
         </web:LTLRateShipmentRequest> 
      </web:LTLRateShipment> 
   </soapenv:Body> 
</soapenv:Envelope>

Qualquer sugestão / direção apreciada!

questionAnswers(1)

yourAnswerToTheQuestion