1. Malek Taha
  2. PowerBuilder
  3. Friday, 5 November 2021 18:01 PM UTC

Hi 

    I have an application written in PB.net that sends an xml request to UPS web service and gets a response back.

It is no longer supported in PB2019R# and i need help replacing the code .

If you can help me it will be greatly appreciated.

Thanks

Malek

 

Function talktoups(string asurl, string asrequest , REF string asresponse)

// this function uses the web post to communicate with UPS web services via XML documents
// the process issues a request by sending an XML document to a URL and receives back an XML document.

 


#if defined PBDOTNET then

try

GMaPSCommon.gasecurity.tls12()

@System.IO.StringWriter sWriter
@System.Net.HttpWebRequest myHttpWebRequest
@System.Net.WebRequest myWebRequest
@System.Net.WebResponse myWebResponse
@System.IO.Stream stream
@System.IO.StreamReader myReader
@System.IO.StreamWriter myWriter


myWebRequest = @System.Net.WebRequest.Create(asURL)
myHttpWebRequest = myWebRequest
myHttpWebRequest.Method = "POST"

myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
myHttpWebRequest.ContentLength = len(asRequest)

//send request using stream writer
stream = myHttpWebRequest.GetRequestStream()
myWriter = Create @System.IO.StreamWriter(stream)
myWriter.Write(asRequest)
myWriter.Close()

//receive response using stream reader
myWebResponse = myHttpWebRequest.GetResponse()
stream = myWebResponse.GetResponseStream()
myReader = Create @System.IO.StreamReader(stream)
asResponse = myReader.ReadToEnd()


catch (@System.Exception e)
messagebox("Talk To UPS Error", e.Message)

end try

#end if

 


return 0

 

 

Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 5 November 2021 18:31 PM UTC
  2. PowerBuilder
  3. # 1

Use  the new HTTPClient in PB 2019 R3 to call the API.

Use PBDOM to parse the XML.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.