1. Joseph Neville
  2. PowerBuilder
  3. Wednesday, 26 September 2018 23:02 PM UTC

I am working on invoking a SOAP web service using httpClient, but when I call the PostDataStart function, I get the return code -1, which according to https://www.appeon.com/support/documents/appeon_online_help/pb2017r3/powerscript_reference/ch10s456.html, is a general error. 

Here's my code:

httpClient lo_client
Constant Integer SECURE_PROTOCOL_TLS12 = 5
integer i
String lo_xml_request
lo_xml_request = ''
lo_xml_request = lo_xml_request + ""
lo_xml_request = lo_xml_request + "<" + web_method + "xmlns=" + xml_namespace + 'xmlns:i="http://www.w3.org/2001/XMLSchema-instance">'
lo_xml_request = lo_xml_request + arguments[1]
for i = 2 to UpperBound(arguments[]) - 1
	lo_xml_request = lo_xml_request + "<" + arguments[i] + ">"
	lo_xml_request = lo_xml_request + arguments[i + 1]
	lo_xml_request = lo_xml_request + ""
    i++
next
lo_xml_request = lo_xml_request + ""
lo_xml_request = lo_xml_request + ""
lo_xml_request = lo_xml_request + ""
lo_client = Create httpClient
lo_client.SecureProtocol = SECURE_PROTOCOL_TLS12
lo_client.SetRequestHeader("Content-Type", "text/xml; charset=utf-8")
lo_client.SetRequestHeader("SOAPAction", soap_action)
if (lo_client.PostDataStart(url) = 1 ) then
	lo_client.PostData(string(lo_xml_request), 1024)
else
	return false
end if
return true

Am I doing something wrong that would cause the PostDataStart function to return -1?

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 26 September 2018 23:57 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Joseph;

  I am not sure but ... do you not have to set the Content length as well?

SetRequestHeader("Content-Length", "1024")

Regards ... Chris

Comment
  1. Joseph Neville
  2. Thursday, 27 September 2018 00:07 AM UTC
Yep, that was it.

I added lo_client.SetRequestHeader("Content-Length", string(len(lo_xml_request))) and 1 was returned!



Thanks Chris
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 27 September 2018 03:59 AM UTC
Excellent news Joseph!
  1. Helpful
There are no comments made yet.
Andres Slachevsky Accepted Answer Pending Moderation
  1. Friday, 7 December 2018 11:49 AM UTC
  2. PowerBuilder
  3. # 1

I will try the solution maybe it can solve my problem 

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.