Jump to content

Calling ASP.NET web service and need an XML object


Svideo

Recommended Posts

I'm trying to use a ASP.NET webservice and new to php I am unsure as how the XML segment required in the add CreatePurchase call gets turned into an object that the web service and php server can use? WSDL is at the top and code lower.

 

 

<s:element name="CreatePurchase"><s:complexType><s:sequence><s:element minOccurs="0" maxOccurs="1" name="axCustomer"><s:complexType><s:sequence><s:any/></s:sequence></s:complexType></s:element></s:sequence></s:complexType></s:element>


Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <CreatePurchase xmlns="http://xxx.xxx.com/webservices/">
      <axCustomer>xml</axCustomer>
    </CreatePurchase>
  </soap12:Body>
</soap12:Envelope


<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

$soapURL = "http://www.xxx.com/ActService/ActService.asmx?WSDL";

$client = new SoapClient($soapURL);

$result = $client->Login(array(
        "asUserName" => "xxx",
        "asPasssword" => "xxx"
));

var_dump($result);

$name = "Ron Howard";
$email = "rh@xxx.com";
$firstname = "Ron";
$lastname = "Howard";
$salutation = "Mr.";
$company = "RHP";
$address = "1313 Mockingbird Lane";
$address2 = "";
$city = "LA";
$statecode = "CA";
$countryISOcode = "USA";
$postcode = "99999";
$phone = "8888888";
$fax = "8888888";
$comments = "test 1";
$purchasedate = date("m/d/Y");



$writer = new XMLWriter();

$writer->openMemory();
$writer->setIndent(4);
$writer->startElement('Customer');
$writer->writeAttribute('Name', $name);
$writer->writeAttribute('EMail', $email);
$writer->writeAttribute('FirstName', $firstname);
$writer->writeAttribute('LastName', $lastname);
$writer->writeAttribute('Salutation', $salutation);
$writer->writeAttribute('Company', $company);
$writer->writeAttribute('Address', $address);
$writer->writeAttribute('Address2', $address2);
$writer->writeAttribute('City', $city);
$writer->writeAttribute('StateCode', $statecode);
$writer->writeAttribute('CountryISOcode', $countryISOcode);
$writer->writeAttribute('PostCode', $postcode);
$writer->writeAttribute('Phone', $phone);
$writer->writeAttribute('Fax', $fax);
$writer->writeAttribute('Comments', $comments);

$writer->startElement('Purchase');

$writer->writeAttribute('LicenseID', '0');
$writer->writeAttribute('PurchaseDate', $purchasedate);
$writer->writeAttribute('Income', '0');
$writer->writeAttribute('Comments', 'Test');

$writer->endElement();
$writer->endElement();

$Customer1 = ($writer->outputMemory(True));

$xml = new xml($Customer1); <<<<<<<<<< ---- How do I turn this into the XML object that is needed in the call?

$result2 = $client->CreatePurchase(array('xml' => $xml));

var_dump($result2);

$result1 = $client->Logout();
var_dump($result1);

?>

 

Regards...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.