1. JOSE WILLIAM ROMERO OLIVOS
  2. PowerBuilder
  3. Thursday, 6 July 2023 16:20 PM UTC
Good day.

Can someone help me what I am doing wrong or what I am missing to consume a SOAP webservice.

This is my code in PowerBuilder 2022.

string ls_url
string token_empresa
string token_password

ls_url ='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
token_empresa='yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
token_password ='zzzzzzzzzzzzzzzzzzzzzzzzzzzz'

HttpClient lo_client
integer li_ret , i , li_StatusCode
String lo_xml_request
string ls_data
string ls_body
string ls_ret


ls_body='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> '+&
' <soapenv:Header/>'+&
' <soapenv:Body>'+&
' <tem:FoliosRestantes>'+&
' <!--Optional:-->'+&
' <tem:tokenEmpresa>'+token_empresa+'</tem:tokenEmpresa>'+&
' <!--Optional:-->'+&
' <tem:tokenPassword>'+token_password+'</tem:tokenPassword>'+&
' </tem:FoliosRestantes>'+&
' </soapenv:Body>'+&
'</soapenv:Envelope>'

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



Lo ejecuto pero me da el siguiente error:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault></s:Body></s:Envelope>

What am I doing wrong? This is applying the examples and guide of appeon.

If I run a SOAP test in SOAPUI the Response is correct, but in Powerbuilder it doesn't work for me

Thanks for the help



 

JOSE WILLIAM ROMERO OLIVOS Accepted Answer Pending Moderation
  1. Friday, 7 July 2023 14:05 PM UTC
  2. PowerBuilder
  3. # 1

Solution

 

lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "text/xml; charset=utf-8")

 

//The SOAPAction parameter must be sent

lo_client.SetRequestHeader("SOAPAction", ls_soap_action)

 

 

 

 

Comment
  1. John Fauss
  2. Friday, 7 July 2023 14:32 PM UTC
Thank you for explaining the solution, Jose!
  1. Helpful 1
There are no comments made yet.
Marcelo Gil Accepted Answer Pending Moderation
  1. Friday, 7 July 2023 12:59 PM UTC
  2. PowerBuilder
  3. # 2

Hi Chris!
The example of the url is understood.
But how can you achieve an automation of the XML message that was previously resolved by the SOAP PROXY when parameters are complex structures of multilevel arrays as in https://servicios1.afip.gov.ar/wsfev1/service.asmx?
So far I didn't find a way to figure out how to build the body xml efficiently for url like

Can you give me some recommendation?

Comment
  1. Chris Pollach @Appeon
  2. Friday, 7 July 2023 13:03 PM UTC
Hi Marcelo;

For XML parsing & generation, you need to use PB's PBDOM feature.

Regards ... Chris
  1. Helpful
  1. Marcelo Gil
  2. Friday, 7 July 2023 14:00 PM UTC
Any possibility that you know of being able to use the dll library that generated the previous Proxy service? Or the only way is using PBDOM?

Thanks for everything
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 7 July 2023 14:30 PM UTC
I am sure that there are 3rd party libraries for XML that you could use or write a small C# .Net DLL that PB Apps can now call natively but for built-in XML processing, the PBDOM feature is the only way for now (unless of course you want to hand script processing the XML data stream and parse it yourself via your own PowerScript).
  1. Helpful
There are no comments made yet.
JOSE WILLIAM ROMERO OLIVOS Accepted Answer Pending Moderation
  1. Thursday, 6 July 2023 23:27 PM UTC
  2. PowerBuilder
  3. # 3

Thank you all for your help and attention. But I was able to fix it. the problem was the soapAction on the HeaderRequest.

Comment
  1. John Fauss
  2. Friday, 7 July 2023 01:59 AM UTC
Can you please provide some additional details? What were the before/after values you modified? I'm sure anyone else experiencing this issue will want to know what you changed. Thanks!
  1. Helpful
There are no comments made yet.
JOSE WILLIAM ROMERO OLIVOS Accepted Answer Pending Moderation
  1. Thursday, 6 July 2023 20:23 PM UTC
  2. PowerBuilder
  3. # 4
WebService SOAP is fine. But by Powerbuilder 2022 it gives me that error.

What am I doing wrong?
Attachments (1)
Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 6 July 2023 18:15 PM UTC
  2. PowerBuilder
  3. # 5
Comment
  1. JOSE WILLIAM ROMERO OLIVOS
  2. Thursday, 6 July 2023 20:18 PM UTC


Thank you. But the same code of the page in reference, is the same that I have in this post. But it doesn't work for me, it generates that error, but the webservice is correct because I try it in SOAPUI and it's fine.
  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.
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.