ericaalicen
Programmer
I'm in way over my head. I code in coldfusion and have had a project dropped in my lap that requires me to send an xmlRequest in PHP and the example code I've been given is in ASP. This is the sample code, I've changed the url for privacy protection.
And this is what I've done in my weak attempt to convert to PHP.
The server is supposed to respond back with something like:
It's a different message if the code is not processed correctly, but same idea.
I don't know how to get the response. I imagine my code will crash even before I get that far at the moment.
Any pointers would be greatly appreciated.
Code:
<%@ Language=vbScript%>
<%
Dim xmlRequest, xmlHttp
xmlRequest = "xmlRequest=<EstimateRequest><ReferralCode>3</ReferralCode><PrimaryContact>
<Email>hfieger@indigio.com</Email><FirstName>Henry</FirstName><LastName>
Fieger</LastName><PrimaryPhoneType>H</PrimaryPhoneType>
<PreferredContactTime>A</PreferredContactTime><HomePhone>3035551234
</HomePhone><WorkPhone>2223334444</WorkPhone><WorkPhoneExt>112
</WorkPhoneExt><CellPhone>2223334444</CellPhone><FaxPhone>2223334444
</FaxPhone></PrimaryContact><PickupAddress><Address1>410 17th St</Address1><Address2></Address2><City>Denver</City><State>CO</State>
<Zip>80202</Zip></PickupAddress><MoveDetails><PickupZip>80202</PickupZip>
<DeliveryZip>80110</DeliveryZip><MoveDate>5/1/2004</MoveDate><DwellingType>
H3</DwellingType><AmountOfFurnishings>M</AmountOfFurnishings>
<PickupShuttle>Y</PickupShuttle><DeliveryShuttle>N</DeliveryShuttle>
</MoveDetails><EstimateDetails><HasVehicles>Y</HasVehicles>
<RequestedEstimateDate>3D</RequestedEstimateDate>
<RequestedEstimateTimeOfDay>A</RequestedEstimateTimeOfDay><SpecialtyItems>
Hello</SpecialtyItems><Comments>World</Comments></EstimateDetails>
</EstimateRequest>"
Set xmlHttp = server.Createobject("MSXML2.ServerxmlHttp")
xmlHttp.Open "POST","[URL unfurl="true"]http://url.url.com/RAE/RequestAnEstimate.asmx/[/URL]
SendEstimateRequestXmlString", False
xmlHttp.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
xmlHttp.send xmlRequest
Response.ContentType = "text/xml"
Response.Write xmlHttp.responsexml.xml
Set xmlHttp = Nothing
%>
And this is what I've done in my weak attempt to convert to PHP.
Code:
<?php
Dim xmlRequest, xmlHttp;
xmlRequest = "xmlRequest=<EstimateRequest><ReferralCode>3</ReferralCode><PrimaryContact>
<Email>$myrow[Email]</Email><FirstName>$myrow[FirstN]</FirstName><LastName>
$myrow[LastN]</LastName><PrimaryPhoneType>H</PrimaryPhoneType>
<PreferredContactTime></PreferredContactTime><HomePhone>$myrow[Area]$myrow
[Pre]$myrow[Phone]</HomePhone><WorkPhone>$myrow[AreaW]$myrow[PreW]$myrow
[PhoneW]</WorkPhone><WorkPhoneExt></WorkPhoneExt><CellPhone></CellPhone>
<FaxPhone></FaxPhone></PrimaryContact><PickupAddress><Address1></Address1>
<Address2></Address2><City>$myrow[CityOrg]</City><State>$myrow[StateOrg]
</State><Zip>$myrow[ZipOrg]</Zip></PickupAddress><MoveDetails><PickupZip>
$myrow[ZipOrg]</PickupZip><DeliveryZip>$myrow[ZipDes]</DeliveryZip>
<MoveDate></MoveDate><DwellingType></DwellingType><AmountOfFurnishings>
</AmountOfFurnishings><PickupShuttle></PickupShuttle><DeliveryShuttle>
</DeliveryShuttle></MoveDetails><EstimateDetails><HasVehicles>
</HasVehicles><RequestedEstimateDate></RequestedEstimateDate>
<RequestedEstimateTimeOfDay></RequestedEstimateTimeOfDay><SpecialtyItems>
</SpecialtyItems><Comments>Trailer Length:$myrow[Length] ft. Quote Amount:\$$myrow[TotalCost] Comments:$myrow[Notes]</Comments></EstimateDetails></EstimateRequest>";
Set xmlHttp = server.Createobject("MSXML2.ServerxmlHttp");
xmlHttp.Open "POST","[URL unfurl="true"]http://url.url.com/RAE/RequestAnEstimate.asmx/[/URL]
SendEstimateRequestXmlString", False;
xmlHttp.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded";[/URL]
xmlHttp.send xmlRequest;
$txt = "text/xml";
echo xmlHttp.responsexml.xml;
Set xmlHttp = Nothing;
?>
The server is supposed to respond back with something like:
Code:
<?xml version="1.0" encoding="utf-8" ?>
- <EstimateResponse xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns="[URL unfurl="true"]http://url.url.com/RAE/">[/URL]
<MoveId>979</MoveId>
<ErrorList />
</EstimateResponse>
It's a different message if the code is not processed correctly, but same idea.
I don't know how to get the response. I imagine my code will crash even before I get that far at the moment.
Any pointers would be greatly appreciated.