Hejsa, jeg skal poste ordredata til en leverandør... de benytter SOAP og har ingen dokumentation på det udover den rene XML...
jeg laver nedenstående post så får jeg denne error fra serveren.. :-(
"Server was unable to process request. ---> Object reference not set to an instance of an object."
er det ikke muligt at benytte nedenstående metode til SOAP ?
- $pathtoxmlserver = "http://webservice.despec.dk/Aws.asmx"; //Relative path to the file with $_POST parsing
-
-
- $produkter = mysql_query("SELECT product_quantity,product_name,product_price,product_reference,product_ean13 FROM ps_order_detail WHERE id_order = '$ordrenummer' AND product_ean13 = '$bestilleshos'");
-
-
- //////////////////////////////////////////////start XML//////////////////////////////////////////////////////////
- $writer = new XMLWriter();
-
-
-
- //skriv til memory
- $writer->openMemory();
-
- $writer->startDocument('1.0','UTF-8');
- $writer->setIndent(4);
-
-
-
-
- $writer->startElement('soap:Envelope');
- $writer->WriteAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
- $writer->WriteAttribute('xmlns:xsd','http://www.w3.org/2001/XMLSchema');
- $writer->WriteAttribute('xmlns:soap','http://schemas.xmlsoap.org/soap/envelope/');
- $writer->startElement('soap:Body');
-
- $writer->startElement('NSCreateOrder_001');
- $writer->WriteAttribute('xmlns','http://schemas.nextinnovation.com/Aws/Sys.asmx');
-
-
-
-
- //ORDER HEADER
-
-
- $writer->startElement('OrderRequest');
- $writer->startElement('Header');
-
- $writer->startElement('Username');
- $writer->text($despecxmllogin);
- $writer->endElement();
-
- $writer->startElement('Password');
- $writer->text($despecxmlpassword);
- $writer->endElement();
-
- $writer->endElement();
-
- $writer->startElement('OrderHead');
-
- $writer->startElement('SystemPO');
- $writer->text($ordre);
- $writer->endElement();
-
- $writer->startElement('ShopPO');
- $writer->text($ordre);
- $writer->endElement();
-
- $writer->startElement('EndCustomerPO');
- $writer->text($ordre);
- $writer->endElement();
-
- $writer->startElement('GoodsLabel');
- $writer->text('');
- $writer->endElement();
-
-
- //ORDER HEADER SLUT
-
- //LEVERINGSADRESSE START
-
- $writer->startElement('ShipToAddress');
-
- $writer->startElement('Attention');
- $writer->text($fuldenavn);
- $writer->endElement();
-
- $writer->startElement('ShipToAdress1');
- $writer->text($adresse0);
- $writer->endElement();
-
- $writer->startElement('ShipToAdress2');
- $writer->text($adresse1);
- $writer->endElement();
-
- $writer->startElement('ShipToAdress3');
- $writer->text('');
- $writer->endElement();
-
- $writer->startElement('ShipToCity');
- $writer->text($by);
- $writer->endElement();
-
- $writer->startElement('PostalCode');
- $writer->text($postnr);
- $writer->endElement();
-
- $writer->startElement('Country');
- $writer->text('DK');
- $writer->endElement();
-
- $writer->endElement();
- $writer->endElement();
-
- //LEVERINGSADRESSE SLUT
-
-
- //ORDRELINJER START
-
-
- $writer->startElement('OrderLines');
-
- $i = 1;
- // produkter hentes fra databasen, loopes 1.gang for hvert produkt
- while ($row = mysql_fetch_array($produkter))
- {
- $produkt = international($row['product_name']);
- $produktpris = $row['product_price'];
- $produktprisexmoms = $produktpris*0.8;
- $produktantal = $row['product_quantity'];
- $produktvarenr = $row['product_reference'];
- $distributor = $row['ean13'];
- $distvarenummeret[] = $produktvarenr;
-
- $writer->startElement('OrderLine');
- $writer->WriteAttribute('lineId',$i);
-
-
- $writer->startElement('SKU');
- $writer->text($produktvarenr);
- $writer->endElement();
- $writer->startElement('Quantity');
- $writer->text($produktantal);
- $writer->endElement();
-
-
- $writer->endElement();
-
- $i++;
- }
- // produkter hentet fra databasen, loop slut
-
-
- $writer->endElement();
- $writer->endElement();
-
-
-
-
- $writer->endElement();
- $writer->endElement();
- $writer->endElement();
-
-
-
-
-
- $writer->endDocument();
-
-
-
- //skriv til memory
- $xmlstrengen = $writer->outputMemory();
-
-
- //print_r($xmlstrengen);
-
-
-
-
- // XML dokument Sendes fysisk her.:
-
- $ch = curl_init($pathtoxmlserver); //Initialise curl resource with above file
-
- $headers = array(
- 'Content-type: text/xml;charset="utf-8"',
- 'Content-length: '.strlen($xmlstrengen),
- 'SOAPAction: "http://schemas.nextinnovation.com/Aws/Aws.asmx/NSCreateOrder_001"'
-
- );
-
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlstrengen);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- //curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
- //$header_array = Array( "Content-Type: text/xml", "SOAPAction: NSCreateOrder_001" );
- //curl_setopt ($ch, CURLOPT_HTTPHEADER, $header_array);
-
-
- $val = curl_exec($ch);
- curl_close($ch); //Close curl session