1. Mitch Goldstein
  2. PowerBuilder
  3. Tuesday, 29 December 2020 18:17 PM UTC
 
I'm having an issue creating an install package for my application.  When I install on a clean computer (no PB installed), I receive an error
 
Application Terminated
"Error: The underlying connection was closed. An unexpected error occurred on a send". 
 
The error happens on the bolded line below.

string ls_connect_url, ls_ret, ls_tmp, soaperror, rterror
long ll_ret, lLog
integer li_pos, li_ret
repoverapimanagement1 lpo_proxy_obj2
wbsrv_soapconnection2 = CREATE SoapConnection

messagebox("debug","checking repository version")

is_repo_site='abcreporting.mus-tr.com'
ls_connect_url="https://mus-tr.com/Services/APIManagement.asmx"

TRY
ll_ret = wbsrv_soapconnection2.Createinstance( lpo_proxy_obj2, 'repoverapimanagement1',ls_connect_url)
CATCH (runtimeerror er)
MessageBox("Runtime Error", er.GetMessage())
FINALLY
END TRY

CHOOSE CASE ll_ret
CASE 100
     MessageBox("Webservice Proxy Creation Error","Invalid Proxy Name")
     return -1
CASE 101
     MessageBox("WebService Proxy Creation Error","Failed to create Proxy")
     return -1
END CHOOSE

messagebox("debug","before check version")
ls_ret=lpo_proxy_obj2.getapiversioninfo ("V1.1")
messagebox("debug - check version",ls_ret)
 
 
 
lpo_proxy_ob2 is the repoverapimanagement1, a Proxy object imported from Web service using Web Service Proxy Generator.  It has the getapiversioninfo function.  I exported the object and here's the contents:
 
$PBExportHeader$repoverapimanagement1.srx
$PBExportComments$Proxy imported from Web service using Web Service Proxy Generator.
global type repoverAPIManagement1 from NonVisualObject
end type

type variables
Protected:
string pbws_ver = ".NET"
string cs_namespace = "WebService"
string cs_class = "APIManagement1"
string cs_assembly = "musrepover.dll"
string pb_prefix = "repover"
string pb_usenvo = "YES"
string pb_target = "C:\dev11\minuscript4.0"
end variables

forward prototypes
public:
function string GetAPIVerions() alias for "<method name='GetAPIVerions' ns='WebService' pbname='GetAPIVerions'><return name='returnvalue' type='System.String' isRef='False' ArrayDim='0' IsNullableType='False' /></method>"
function string GetAPIVersionInfo( string versionNumber) alias for "<method name='GetAPIVersionInfo' ns='WebService' pbname='GetAPIVersionInfo'><return name='returnvalue' type='System.String' isRef='False' ArrayDim='0' IsNullableType='False' /><param name='versionNumber' type='System.String' pos='0' dir='in' ArrayDim='0' IsNullableType='False'/></method>"
subroutine CancelAsync ( any userState) alias for "<method name='CancelAsync' ns='WebService' pbname='CancelAsync'><param name='userState' type='System.Object' pos='0' dir='in' ArrayDim='0' IsNullableType='False'/></method>"
subroutine PBAddCookie(any cookie) alias for "<method name='PBAddCookie' ns='System.Runtime.Remoting.Messaging' IsCookieFunction='True' pbname='PBAddCookie'><return name='returnvalue' type='System.Void' isRef='false' ArrayDim='0' IsNullableType='false' /><param name='cookie' type='any' pos='0' dir='in' ArrayDim='0' IsNullableType='False'/></method>"
function any PBGetCookies(string Uri) alias for "<method name='PBGetCookies' ns='System.Runtime.Remoting.Messaging' IsCookieFunction='True' pbname='PBGetCookies'><return name='returnvalue' type='System.Object' isRef='false' ArrayDim='0' IsNullableType='false' /><param name='cookie' type='System.String' pos='0' dir='in' ArrayDim='0' IsNullableType='False'/></method>"
end prototypes
 
Let me know if there is anything else I can add to help.
 
Mitch
Attachments (1)
Accepted Answer
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Thursday, 31 December 2020 20:47 PM UTC
  2. PowerBuilder
  3. # Permalink
0
Votes
Undo

Sounds like a client machine config issue. If you use HTTPClient you should no longer have such hassles, plus you get better security with TLS 1.2 and tech support. Here is tech article how to use HTTPClient to call SOAP: https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/236-call-soap-web-services-using-httpclient-object

 

Comment
Ameen, you are right! I've started switching my code to use HTTPClient and so far I'm three for three on converting my calls and tested on two computers which were having issues with the proxy method. Chris Pollach also mentioned HTTPClient as a possible solution. I have a bit of code to covert and was hesitant going down that path because I didn't know how much work it would be to convert, but this seems like the best solution. THANK YOU!



AND THANK EVERYONE ELSE FOR HELPING.



Happy New Year!
  1. Mitch Goldstein
  2. Friday, 1 January 2021 17:01 PM UTC
Glad to hear the new feature we added is working well for you!
  1. Armeen Mazda @Appeon
  2. Friday, 1 January 2021 19:22 PM UTC
That's awesome news Mitch!
  1. Chris Pollach @Appeon
  2. Friday, 1 January 2021 21:21 PM UTC
There are no comments made yet.
Arthur Hefti Accepted Answer Pending Moderation
  1. Friday, 1 January 2021 10:13 AM UTC
  2. PowerBuilder
  3. # 1
0
Votes
Undo

Hi

as Armeen and Kevin already mentioned it's a TLS version problem. I called you WS from PB and from XML Spy and had Fiddler capturing the data. PB uses TLS 1.0 where XML Spy uses TLS 1.2. PB doesn't work with the error you have and XML Spy works. 

I found an article by Microsoft how to set the configure the .NET Framework (see below) to use TLS 1.1 and 1.2 and use the default version set in the systems. You need to set the following registry key:

KEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319

After setting this I can call your WebService.

Regards
Arthur

https://docs.microsoft.com/en-us/mem/configmgr/core/plan-design/security/enable-tls-1-2-client 

Comment
That means that the .Net framework was not installed properly. If it had, then this registry setting would have been there. That's why when I asked if the .Net runtime was listed in the installed apps of the Control Panel - the answer was no. Whereas if it was installed properly, then it should have been listed. ;-)
  1. Chris Pollach @Appeon
  2. Friday, 1 January 2021 14:59 PM UTC
Hi Chris



The PB Soap WS is using targeting .NET4.0 and uses by default TLS 1.0. So you can either decompile the DLL and try to add the protocol settings or add/set the registry key.
  1. Arthur Hefti
  2. Friday, 1 January 2021 17:50 PM UTC
Hi Arthur ... That doesn't make sense as it works from Mitch's development PC but not on his deployment PCs. The PB WS apps should be targeting .Net 4.8 as well not 4.0 in order to work correctly.
  1. Chris Pollach @Appeon
  2. Friday, 1 January 2021 21:25 PM UTC
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Thursday, 31 December 2020 19:40 PM UTC
  2. PowerBuilder
  3. # 2
0
Votes
Undo

There's a few things to look into and try. 

  • #1 (this probably won't help in this case but it's good practice) - use a try/catch for your method call and catch soapexception
  • Often this error occurs when TLS 1.0 is turned off on the server that the webservice runs on.
  • Are you able to successfully run it using Postman or SoapUI? (if so you can trap the request and recreate it using the HTTPClient object.
  • Fiddler is super helpful debugging webservices.  You get to see the exact request and response.

 

Chances are it's probably the TLS 1.0 being disabled, but try the other suggestions as well.  The method you are using to consume the WSDL and create the proxy objects isn't supported anymore as far as I know, so you should probably upgrade to using the HTTPClient object anyway.

 

Kevin

Comment
Check whether TLS 1.0 is enabled on your client machine as well.
  1. Kevin Ridley
  2. Thursday, 31 December 2020 19:41 PM UTC
Kevin, thanks for your response.



- I added the TRY/CATCH and it displayed my same error message and not additional info. Is this how you'd set that up?



TRY

ls_ret=lpo_proxy_obj2.GetAPIVerions()

CATCH (runtimeerror er)

MessageBox("Runtime Error", er.GetMessage())

FINALLY

END TRY



- The code works fine when I'm on my developer machine, so I would assume that the server TLS settings are correct, right? This is also code which worked on client computers prior to upgrade to recent PB and also we had to move our app server. But I felt the app server was working correctly since I don't have an issue with running from either PB developer tool or compiled code on my developer computer.



- TLS 1.0, 1.1 & 1.2 are all enabled on test laptop



- I'm open to changing to HTTPClient if we think this would be easier to get to work. If, are there any changes that need to be done on the server side, or is this just changes in my app?



Thanks again!

Mitch







  1. Mitch Goldstein
  2. Thursday, 31 December 2020 20:30 PM UTC
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 29 December 2020 18:56 PM UTC
  2. PowerBuilder
  3. # 3
0
Votes
Undo

Hi Mitch;

  You might want to ...

  1. Reformat this post so that we can read it
  2. Give us some more details as to the type of WS, how its used, snippet of actual code, screen captures of the errors / issues, etc

Regards ... Chris

Comment
Hmmm ... I do not see any screen shot attachement. :-(
  1. Chris Pollach @Appeon
  2. Thursday, 31 December 2020 18:17 PM UTC
Looks like I added to wrong place. Check again. Also, let me know if sending you the installation program would help.
  1. Mitch Goldstein
  2. Thursday, 31 December 2020 18:45 PM UTC
If the WS call is public in your Test App, then publishing this would be of great help IMHO.
  1. Chris Pollach @Appeon
  2. Thursday, 31 December 2020 19:51 PM UTC
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 29 December 2020 18:48 PM UTC
  2. PowerBuilder
  3. # 4
0
Votes
Undo

If the free community support is not getting your issue resolved, you may want to purchase a premium support ticket and get help directly from Appeon.

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.