Page 1 of 1

PHP/SOAP with .NET web service

Posted: Thu May 26, 2005 2:25 pm
by sse266
Hello,

I am new to developing with PHP after having worked with ASP for 5 years. I have created a SOAP object with an ASP script that I do not know how to convert to PHP. Here is my code:

Code: Select all

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Create the SOAP object to submit the data to the server.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Begin by creating our SOAP formatted string

'POST http://ems-sql.equitymarketing.com/pmse ... vices.asmx HTTP/1.1
'Host: ems-sql.equitymarketing.com
'Content-Type: text/xml; charset=utf-8
'Content-Length: length
'SOAPAction: "http://www.equitymarketing.com/ImportCustomerData"

dim strSOAPmsg

strSOAPmsg = "<?xml version=""1.0"" encoding=""utf-8""?>"
strSOAPmsg = strSOAPmsg & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
strSOAPmsg = strSOAPmsg & "  <soap:Body>"
strSOAPmsg = strSOAPmsg & "    <ImportCustomerData xmlns=""http://www.equitymarketing.com/"">"
strSOAPmsg = strSOAPmsg & "      <ProjectIdentifier>Park</ProjectIdentifier>"
strSOAPmsg = strSOAPmsg & "      <CustomerFirstName>" & strFname & "</CustomerFirstName>"
strSOAPmsg = strSOAPmsg & "      <CustomerLastName>" & strLname & "</CustomerLastName>"
strSOAPmsg = strSOAPmsg & "      <Address1>" & strAddress & "</Address1>"
strSOAPmsg = strSOAPmsg & "      <City>" & strCity & "</City>"
strSOAPmsg = strSOAPmsg & "      <StateAbbreviation>" & strState & "</StateAbbreviation>"
strSOAPmsg = strSOAPmsg & "      <ZipCode>" & strZip & "</ZipCode>"
strSOAPmsg = strSOAPmsg & "      <EmailAddress>" & strEmail & "</EmailAddress>"
strSOAPmsg = strSOAPmsg & "      <HomePhone>" & strPhone & "</HomePhone>"
strSOAPmsg = strSOAPmsg & "      <CustomerNotes>" & strQuestions & "</CustomerNotes>"
strSOAPmsg = strSOAPmsg & "    </ImportCustomerData>"
strSOAPmsg = strSOAPmsg & "  </soap:Body>"
strSOAPmsg = strSOAPmsg & "</soap:Envelope>"


set xmldom = server.CreateObject("Microsoft.XMLDOM")
set xmlhttp = server.CreateObject("Microsoft.XMLHTTP")

xmlhttp.open "POST", "http://ems-sql.equitymarketing.com/PMServices/ProjectManagerServices.asmx", false
'xmlhttp.setRequestHeader "POST " & "http://ems-sql.equitymarketing.com/pmservices/projectmanagerservices.asmx" & " HTTP/1.1"
'xmlhttp.setRequestHeader "MessageType", "CALL"
xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
xmlhttp.setRequestHeader "Content-Length", "500"
xmlhttp.setRequestHeader "SOAPAction", "http://www.equitymarketing.com/ImportCustomerData"
xmlhttp.send(strSOAPmsg)


'Anything other than 200 means error.
if xmlhttp.Status = 200 then
  'collects the data returned.
  Set xmldom = xmlhttp.responseXML

  'writes it to the screen.
  Response.write(xmldom.xml)

	'Destroy the objects
	set xmlhttp = nothing
	set xmldom = nothing


	' Redirect (if RedirectUrl is defined by the FORM
	Response.Redirect(strRedirect)

  
'Just some error checking. I use this to see why its messing up.
Else
  Response.Write("Didn't Work<BR>")

 'Writes the error code  returned by the server.
  Response.Write("status=" & xmlhttp.status)

  'Writes the accompanying text.
  Response.write("<BR>" & xmlhttp.statusText)
  Response.Write("<BR>" & Request.ServerVariables("ALL_HTTP"))

	'Destroy the objects
	set xmlhttp = nothing
	set xmldom = nothing

End if

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Any help is greatly appreciated.

Regards,
Scott