1. Gimmy Susan
  2. PowerBuilder
  3. Thursday, 25 February 2021 18:53 PM UTC

Hi

I am converting the old 'web service proxy' calls to the new 'httpclient'.
I'm running the directions in 'https://www.appeon.com/developers/get-help/knowledgebase/call-soap-web-service-using-httpclient-object.html', but it doesn't work. (performed by browser all work well)

To debug I have created a small web service and I ask you for help.

 

 

I have this very simple web service (*) that I have successfully published in my local IIS.
Calling it from the browser everything works.


if I try to call it from Powerbuilder (**) it doesn't work. In particular lo_client.GetResponseStatusCode () returns 500.


Why? Some idea ?

Thanks in advance for the reply

Gimmy

 

p.s.: Ecosystem: Pb2019r3 build 2670 + Runtime 19.2.2670 - windows 10 64bit - 

 

 

 

 

*  web service code:

=============

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data;
using Newtonsoft.Json;
using System.Data;
using Oracle.ManagedDataAccess.Client;

namespace ProgenAM
{
[WebService(Namespace = "http://ateikon.com/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]

public class CoGe : System.Web.Services.WebService
{
[WebMethod]
public string xxx(string _cdazie)
{
return _cdazie + " add something";
}
}
}

 

(**) Powerbuilder code

===========

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

ls_url ="http://www.jakaa.locale/Coge.asmx"
ls_body = '<?xml version="1.0" encoding="utf-8"?>'+&
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+&
' <soap:Body>'+&
' <xxxResponse xmlns="http://ateikon.com/webservices/">'+&
' <xxxResult>Gimmy</xxxResult>'+&
' </xxxResponse>'+&
' </soap:Body>'+&
'</soap: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

 

Accepted Answer
Gimmy Susan Accepted Answer Pending Moderation
  1. Tuesday, 26 October 2021 08:03 AM UTC
  2. PowerBuilder
  3. # Permalink

i solved the problem internally

Comment
  1. Armeen Mazda @Appeon
  2. Tuesday, 26 October 2021 15:56 PM UTC
What was the problem?
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Monday, 1 March 2021 14:22 PM UTC
  2. PowerBuilder
  3. # 1

I have found over the years that it's much easier to get the service working with SoapUI or Postman first, then see what the working request looks like (some like using Fiddler also to trap the request/response).  Then duplicate it in PB using the httpclient.  Many SOAP services that were developed years ago are now also available as REST too.  Sometimes it's easier to work with REST.  I know the example you used was a simple service you developed in house, but when you need to call external web services, check to see if they also offer a REST version.

 

Kevin

Comment
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Monday, 1 March 2021 04:58 AM UTC
  2. PowerBuilder
  3. # 2

Hi Gimmy,

 

I verified your test case and found that your Web Server doesn't support Request format as application/xml.

I used Fiddler to monitor your web service port and found that the supported format of your Web Service is application/x-www-form-urlencoded.

I suggest you try the below PB code to see if it could work around your issue.

 

ls_url ="http://www.jakaa.locale/Coge.asmx/xxx"
 
ls_body = "_cdazie=abc123"
lo_client = Create httpClient
lo_client.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
 
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

 

 

Regards,

 

Comment
  1. Gimmy Susan
  2. Monday, 1 March 2021 10:50 AM UTC
Thanks for the reply.



With your suggestion the ws actually works.



Now that I have to drop the tests and have to bring the experience back to the original programs, I have 2 issues to clarify:

1. my problem was generated by the iis configuration or did I do something wrong in writing the webservice?

2) what should i do if i want to pass more than one parameter?



thanks in advance for the answer.
  1. Helpful
  1. Gimmy Susan
  2. Tuesday, 2 March 2021 09:44 AM UTC
Question 2 solved



ls_url ="http://www.jakaa.locale/Coge.asmx/_fake3";

lo_client = Create httpClient

lo_client.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

ls_body=''

ls_body += "f1=parametro1"

ls_body += "&"+"f2=parametro2"

ls_body += "&"+"f3=parametro3"

lo_client.sendrequest('POST',ls_url,ls_body)
  1. Helpful
There are no comments made yet.
Daryl Foster Accepted Answer Pending Moderation
  1. Monday, 1 March 2021 02:31 AM UTC
  2. PowerBuilder
  3. # 3

Hi Gimmy, the Postman example is giving a different response to your Powerbuilder code.  Your Powerbuilder code is giving a 500 error, the Postman example is giving a 415 error.  The 415 error from Postman is usually related to the Content-Type header.  I can see that you've selected XML in your Postman example, but double check the Headers section in the request to see what it actually is.  It might be 'application/xml' instead of 'text/xml'.

I think you might also need to add a SOAPAction header for a SOAP 1.1 request, so you can try to add that in your Powerbuilder code and/or your Postman request

 

For Powerbuilder:

lo_client.SetRequestHeader("SOAPAction", "http://ateikon.com/webservices/xxx")

Comment
There are no comments made yet.
Gimmy Susan Accepted Answer Pending Moderation
  1. Friday, 26 February 2021 07:30 AM UTC
  2. PowerBuilder
  3. # 4
 

Hi Chris

Here is the proof made with Postman.
Unfortunately it doesn't work.


I enclose:
. postman image
. visual studio sources (for obvious reasons it does not include the 'packages' folder)
. Postman reply

Attachments (3)
Comment
  1. Chris Pollach @Appeon
  2. Friday, 26 February 2021 16:11 PM UTC
Hi Gimmy;

If the PostMan software does not work with your WS, then I suspect that it could transpose into PB Issue (challenge) as well. My suggestion now would be to open a Support Ticket and attach your PostMan and VS Solution for Appeon to review the issue with.

Regards ...Chris
  1. Helpful
  1. Gimmy Susan
  2. Friday, 26 February 2021 16:14 PM UTC
ty Chris
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 25 February 2021 20:58 PM UTC
  2. PowerBuilder
  3. # 5

Hi Jimmy;

   Did you try using the free PostMan software product to verify the WS call 1st?

http://www.postman.com/pricing

Regards ... Chris

Comment
  1. Gimmy Susan
  2. Friday, 26 February 2021 07:17 AM UTC
i try
  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.