I need to update a few pages that send a forms based XML string to a site and display the returned values. I am not sure of the C# .NET 2.0 syntax to pull it off and wondered if anyone new of a good place to look. I have searched the web for the past few days and have not been able to come up with anything to help me out.

Recommended Answers

All 5 Replies

Does anyone have a clue on how to do this? Just to clarify further.... Values from a form will populate a XML string that is sent to DHL... Once they get the information they will also return rates to me.

Is this the right forum for this type of question or should I put it in the XML forum too?

Basically something like this, but with C# .Net

RateWrite
    counter = 1	
	Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
	'xmlhttp.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
	xmlhttp.open "POST" ,"http://eCommerce.airborne.com/ApiLandingTest.asp",False
	xmlhttp.setRequestHeader "Content-Type", "text/xml"	
	'xmlhttp.open "POST" ,"https://www.zgraph.net",False
	xmltext ="<?xml version=""1.0"" encoding=""UTF-8""?>"&_
	"<eCommerce action=""Request"" version=""1.1"">"&_
		"<Requestor>"&_
			"<ID>DHLID</ID>"&_
			"<Password>DHLPassword</Password>"&_
		"</Requestor>"
	For x = 0 to 5
		xmltext = xmltext &_
		"<Shipment action=""RateEstimate"" version=""1.0"">"&_
			"<ShippingCredentials>"&_
				"<ShippingKey>1234567</ShippingKey>"&_
				"<AccountNbr>1234567</AccountNbr>"&_
			"</ShippingCredentials>"&_
			"<ShipmentDetail>"&_
				"<ShipDate>"&datePart("yyyy",cDater)&"-"
				If datepart("m",cDater) < 10 Then
					xmltext = xmltext & "0"&datePart("m",cDater)
				Else
					xmltext = xmltext & datePart("m",cDater)
				End If
				xmltext = xmltext & "-"
				If datepart("d",cDater) < 10 Then
					xmltext = xmltext & "0"&datePart("d",cDater)
				Else
					xmltext = xmltext & datePart("d",cDater)
				End If
				xmltext = xmltext & "</ShipDate>"&_
				"<Service>"&_
					"<Code>"&arrMethod(x,0,0)&"</Code>"&_
				"</Service>"&_
				"<ShipmentType>"&_
					"<Code>"&cType&"</Code>"&_
				"</ShipmentType>"
				if cType = "P" and cInsureAmt > 5000 then
				    xmltext = xmltext & _
					"<Weight>"&cWeight&"</Weight>" & _
					"<ContentDesc>"&cShipDesc&"</ContentDesc>" & _
					"<Dimensions>"&_
						"<Length>"&cLength&"</Length>"&_
						"<Width>"&cWidth&"</Width>"&_
						"<Height>"&cHeight&"</Height>"&_
					"</Dimensions>"
				elseif cType="P" then
				    xmltext = xmltext & _
					"<Weight>"&cWeight&"</Weight>" & _
					"<Dimensions>"&_
						"<Length>"&cLength&"</Length>"&_
						"<Width>"&cWidth&"</Width>"&_
						"<Height>"&cHeight&"</Height>"&_
					"</Dimensions>"
				End If
				'Additional Protection
				If StripCommas(cInsureAmt) > 100 Then
				xmltext = xmltext & "<AdditionalProtection>"&_
				"<Code>"&"AP"&"</Code>"&_
				"<Value>"&StripCommas(cInsureAmt)&"</Value>"&_
				"</AdditionalProtection>"
				End if
				'End Additional Protection
				If trim(arrMethod(x,0,1)) <> "" Then
					xmltext = xmltext & _
					"<SpecialServices>" & _
						"<SpecialService>" & _
							"<Code>"&arrMethod(x,0,1)&"</Code>" & _
						"</SpecialService>" & _
					"</SpecialServices>"						
				End If
			xmltext = xmltext & _
			"</ShipmentDetail>" & _
			"<Billing>"&_
				"<Party>"&_
					"<Code>S</Code>"&_
				"</Party>"&_
			"</Billing>"&_
			"<Sender>"&_
			    "<SentBy>" & "The Freight Rate Company" & "</SentBy>"&_
				"<Address>"&_
				    "<CompanyName>The Freight Rate Company</CompanyName>"&_
				    "<Street>123 Main Street</Street>"&_
				    "<City>" & "City" & "</City>"&_
					"<State>"&cStateFrom&"</State>"&_
					"<Country>US</Country>"&_
					"<PostalCode>"&cZipFrom&"</PostalCode>"&_
				"</Address>"&_
			"</Sender>"&_
			"<Receiver>"&_
				"<Address>"&_
				    "<CompanyName>The Freight Rate Company</CompanyName>"&_
				    "<Street>123 Main Street</Street>"&_
				    "<City>" & "City" & "</City>"&_
					"<State>"&cStateTo&"</State>"&_
					"<Country>US</Country>"&_
					"<PostalCode>"&cZipTo&"</PostalCode>"&_
				"</Address>"&_
			"</Receiver>"&_
			"<TransactionTrace>"&_
				"<SpecialType>"&arrMethod(x,0,1)&"</SpecialType>"&_
			"</TransactionTrace>"&_
		"</Shipment>"
	Next
	Set x = nothing
	xmltext = xmltext & "</eCommerce>"

In a nutshell that code takes information from a bunch of textboxes and inserts that information in between the XML string.

Then the string is sent to DHL and they send back a response (another XML string) and I show the results on the page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.