1. Andres Slachevsky
  2. PowerBuilder
  3. Tuesday, 11 December 2018 13:42 PM UTC

Hello All.

i need to call the SOAP WS that use reflection so it can no be handle by tb WS Proxy Object

i manage to send the request using postdata with return 1 with this code:


httpClient lo_client
Constant Integer SECURE_PROTOCOL_TLS12 = 5
integer li_ret , i
String lo_xml_request
string ls_url
string ls_soap_action
string arguments[]
string ls_body
string ls_ret

ls_url =sle_url.text //(https://efxpywsdev.informconf.com.py/Services/Personas.svc)

ls_soap_action =sle_action.text //(http://tempuri.org/IPersonas/DatosPersonales)

lo_xml_request = 'http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">

  

  

     

         MARCELO_CLEMOTTE2_5053

         Marcle0918!

         20.000.000B

         0

     

  

'

 

lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "text/xml; charset=utf-8")
lo_client.SetRequestHeader("SOAPAction", ls_soap_action)
lo_client.SetRequestHeader("Content-Length",string(len(lo_xml_request)*2))
li_ret = lo_client.PostDataStart(ls_url)

li_ret = lo_client.PostData(blob(lo_xml_request),len(lo_xml_request)* 2 )

 

li_ret = lo_client.postdataend()

 

li_ret = lo_client.GetResponseStatusCode()
ls_ret = lo_client.GetResponseStatusText( )

 

i have the return 400 bad request

 

i have try 

also like this:

         MARCELO_CLEMOTTE2_5053

         Marcle0918!

         20.000.000B

         0

     

 

and 

 

         MARCELO_CLEMOTTE2_5053

         Marcle0918!

         20.000.000B

         0

     

in the IIS log i can it returns 400

 

 

 

Andres Slachevsky Accepted Answer Pending Moderation
  1. Thursday, 13 December 2018 11:24 AM UTC
  2. PowerBuilder
  3. # 1

Thanks to all,

now it is working

i found also that when i copy the solution from the e-mail windows add some garbage invisible characters that make the XML invalid

when i copy the XML from the support site it did work.

 

Comment
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Thursday, 13 December 2018 04:58 AM UTC
  2. PowerBuilder
  3. # 2

Hi Andres,

I've updated your ticket 1980. Please use the following code or the attachment to verify if it works for you. (some code lost in the post)

ls_url ="https://efxpywsdev.informconf.com.py/Services/Personas.svc?wsdl"
ls_soap_action ='"http://tempuri.org/IPersonas/DatosPersonales"'
lo_xml_request = ''+&
''+&
''+&
' '+&
' '+&
' MARCELO_CLEMOTTE2_5053'+&
' Marcle0918!'+&
' 20.000.000B'+&
' 0'+&
' '+&
' '+&
''

lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "text/xml;charset=UTF-8")
lo_client.SetRequestHeader("SOAPAction", ls_soap_action)
lo_client.SetRequestHeader("Content-Length",string(len(lo_xml_request) ))
//lo_client.SetRequestHeader("Accept-Encoding", "gzip,deflate")
li_ret = lo_client.sendrequest('POST',ls_url,lo_xml_request )
li_StatusCode = lo_client.GetResponseStatusCode()
ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody( ls_data)
destroy lo_client

 

ls_url ="https://efxpywsdev.informconf.com.py/Services/Personas.svc?wsdl"
ls_soap_action ='"http://tempuri.org/IPersonas/DatosPersonales"'				
lo_xml_request = ''+&
''+&
''+&
'	'+&
'		'+&
'			MARCELO_CLEMOTTE2_5053'+&
'			Marcle0918!'+&
'			20.000.000B'+&
'			0'+&
'		'+&
'	'+&
''

lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "text/xml;charset=UTF-8")
lo_client.SetRequestHeader("SOAPAction", ls_soap_action) 
lo_client.SetRequestHeader("Content-Length",string(len(lo_xml_request) ))
//lo_client.SetRequestHeader("Accept-Encoding", "gzip,deflate")
li_ret = lo_client.sendrequest('POST',ls_url,lo_xml_request )
li_StatusCode = lo_client.GetResponseStatusCode()
ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody(  ls_data)
destroy lo_client

Regards,

Mark Lee

Attachments (2)
Comment
There are no comments made yet.
Andres Slachevsky Accepted Answer Pending Moderation
  1. Wednesday, 12 December 2018 11:26 AM UTC
  2. PowerBuilder
  3. # 3

I am trying to use the Sendrequest but i can no find where to set the soapaction

Comment
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 12 December 2018 09:45 AM UTC
  2. PowerBuilder
  3. # 4

Hi Andres,

I’ve made a simple SOAP web service and I can successfully call the of_test method using the SendRequest or PostData methods of HTTPClient object. See attached for detail.

 

We found that you webservice link is no longer accessible (https://efxpywsdev.informconf.com.py/Services/Personas.svc), so we can’t help you to verify if the HTTPClient also works with your current SOAP webservice. Theoretically, HTTPClient can support SOAP web services.

 

I suggest that you use a third party tool like Postman to test your current link and make sure you can successfully call the service and then re-write your PB code based on the same configuration using the HTTPClient.

 

Additionally, you will need to get a sample SOAP 1.X request and response from your SOAP web services provider to prepare the xml content properly in the ls_body variable.

 

In your case, I suggest that you use the SendRequest method instead of PostData as it is not sending a lot of data or a big file.  

 

Here below is the sample code:

SendRequest :

httpClient lo_client
integer li_ret , i , li_StatusCode
string ls_url ,ls_data,ls_body,ls_ret

ls_url ="http://localhost/invoice/n_webservice.asmx"			
ls_body = ''+&
''+&
'  '+&
'    '+&
'  '+&
''
lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "text/xml")
lo_client.sendrequest('POST',ls_url,ls_body)
li_StatusCode = lo_client.GetResponseStatusCode()
ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody(  ls_data)

destroy lo_client

 

PostData :

httpClient lo_client
integer li_ret, li_StatusCode 
long		i,	ll_len, ll_count
string ls_url ,ls_data,ls_body,ls_ret, ls_newdata, ls_newurl
blob 		lb_data, lb_newdata

ls_url ="http://localhost/invoice/n_webservice.asmx"			
ls_body = ''+&
''+&
'  '+&
'    '+&
'  '+&
''
lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "text/xml")
lb_data = Blob(ls_body, EncodingUTF8!)
lo_client.SetRequestHeader("Content-Length", string(Len(lb_data)))
lo_client.secureprotocol = 0 
ll_count  = Ceiling(len(lb_data) / 1024 ) 
if lo_client.PostDataStart(ls_url) = 1 then
	for i = 1 to ll_count
		lb_newdata = BlobMid(lb_data, (i -1 )* 1024 +1, 1024)
		li_ret = lo_client.PostData(lb_newdata, Len(lb_newdata)  * 2)
		if li_ret <> 1 then exit
	next
end if
if li_ret = 1 then
	li_ret = lo_client.PostDataEnd()
end if
li_StatusCode = lo_client.GetResponseStatusCode()		
ls_ret = lo_client.GetResponseStatusText( )
li_ret = lo_client.getresponsebody( ls_data)
destroy lo_client

 

Regards,

Mark Lee

Attachments (2)
Comment
  1. Andres Slachevsky
  2. Wednesday, 12 December 2018 11:05 AM UTC
Thank mark i will try the send request

i use SOAPUI to test it generates the following request



POST http://efxpywsdev.informconf.com.py/Services/Personas.svc HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: text/xml;charset=UTF-8

SOAPAction: "http://tempuri.org/IPersonas/DatosPersonales"

Content-Length: 529

Host: efxpywsdev.informconf.com.py

Proxy-Connection: Keep-Alive

User-Agent: Apache-HttpClient/4.1.1 (java 1.5)













?



?



?



?









is really the same request i was trying to send

  1. Helpful
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.