how to send an object to C# WCF service from PHP using SOAP
Posted: Thu Jul 22, 2010 1:33 am
Hey all!
I'm having trouble sending a custom object thats defined as a datacontract in my WCF web service from PHP. I'm attempting to accomplish this via SOAP.
The object is called simplyCustomer and pretty much just has a bunch of attributes like name, phone number address, etc. Very generic stuff.
I am able to receive this object in PHP without any problems. It comes in as a stdClass and is very workable. However, when I create the exact same stdClass and attempt to send it back to the WCF service, the SOAP request is somehow set to NULL.
Here is the stdClass:
Here is the function call that I use:
Here is the envelope that is generated:
The parameters should be where addCustomer is but there's nothing there.
Any help would be greatly appreciated! Thanks!
I'm having trouble sending a custom object thats defined as a datacontract in my WCF web service from PHP. I'm attempting to accomplish this via SOAP.
The object is called simplyCustomer and pretty much just has a bunch of attributes like name, phone number address, etc. Very generic stuff.
I am able to receive this object in PHP without any problems. It comes in as a stdClass and is very workable. However, when I create the exact same stdClass and attempt to send it back to the WCF service, the SOAP request is somehow set to NULL.
Here is the stdClass:
Code: Select all
$taxInfoObj = new stdClass;
$taxEntry = new stdClass;
$newCustomer = new stdClass;
$newCustomer->name = "ci_testName";
$newCustomer->contact = "ci_testContact";
$newCustomer->street1 = "ci_testStreet";
$newCustomer->city = "ci_testCity";
$newCustomer->province = "ci_testProvince";
$newCustomer->postalCode = "ci_testPostal";
$newCustomer->country = "ci_testCountry";
$newCustomer->phone1 = "5149876543";
$newCustomer->fax = "5149876542";
$newCustomer->email = "ci_testEmail@company.com";
$newCustomer->website = "www.ci_testWebsite.com";
$newCustomer->languagePref = "ci_testLang";
$newCustomer->shippingContact = "ci_testShipContact";
$newCustomer->shippingStreet1 = "ci_testShipStreet";
$newCustomer->shippingAddressName = "ci_testShipName";
$newCustomer->shippingCity = "ci_testShipCity";
$newCustomer->shippingProvince = "ci_testShipProv";
$newCustomer->shippingCountry = "ci_testShipCountry";
$newCustomer->shippingPostalCode = "ci_testShipPostal";
$newCustomer->shippingPhone1 = "5149876543";
$newCustomer->shippingFax = "5149876542";
$newCustomer->shippingEmail = "ci_testShipEmail@company.com";
$newCustomer->isDefaultShippingAddress = 1;
$newCustomer->taxInfo = array(
$taxInfoObj->ArrayOfstring = array(
$taxEntry->string = array("0",""),
$taxEntry->string = array("0",""),
$taxEntry->string = array("0",""),
$taxEntry->string = array("0",""),
$taxEntry->string = array("0",""),
$taxEntry->string = array("0",""),
$taxEntry->string = array("0","")
)
);
Code: Select all
//Connecting to Bridge Service
$simplyService = new SoapClient('http://192.168.2.36/bridgeService/simply.svc?wsdl',array('trace'=>1));
//build parameter
$params = array('simplyCust'=>$customerObject);
//Send request to Bridge Service
$retVal = $simplyService->__soapCall("addCustomer",array('parameters'=>$params));
$lastRequest = $simplyService->__getLastRequest();
Here is the envelope that is generated:
Code: Select all
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:addCustomer/></SOAP-ENV:Body></SOAP-ENV:Envelope>
Any help would be greatly appreciated! Thanks!