cancel
Showing results for 
Search instead for 
Did you mean: 

Question about WS Security in Powerbuilder 12.5 .NET

Former Member
0 Kudos
148

Background

After watching

"SAP D&T Academy - How to Create a WCF Web Service in PowerBuilder"

So far i have

Created a web service in PowerBuilder 12.5 .NET

Added WS Security to the service, implementing message security with a certificate

Created s WCF client in Visual Studio to consume the service

Added WS Security to the client, implementing message security with a certificate

Called the service from the client and it works flawlessly.

When i try to do the same with a PowerBuilder 12.5 .NET client however i constantly get the error

"Message    "The client certificate is not provided. Specify a client certificate in ClientCredentials. "    string"

Regardless of where in the client I specify the certificate details i get the same error.

Also,whenever i deploy the client application the generated config generated does not have the certificate  details within in it.

Any help would be greatly appreciated

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Did you set the certification in the soapconnection properties

Rgds.

Abdallah.

SoapConnection:

SetClientCertificateFile method

Description

Sets the certificate file or files to use to connect to a Web service. This
method is available for .NET Web services only.

Syntax

conn.SetClientCertificateFile (string filename)


Argument


Description


conn


The name of the SoapConnection object that establishes the
connection.


filename


A string containing the name of the certificate file or files
you want to use to connect to a Web service. You must use a semicolon as a
separator for multiple files. The value can include local files with a full path
and URLs to remote certificate files. To discontinue use of certificates, enter
an empty string ("").

Return Values

Long. Valid values are 0 for
success, and 50 for failure.

Usage

You can call the SetClientCertificateFile method
instead of including certificate information in the options argument of the SetOptions method.

Former Member
0 Kudos

The SoapConnection class does not exist in Powerbuilder 12.5.NET


https://pbdj.sys-con.com/node/1413154

Former Member
0 Kudos

Hi Andre,

You're right. PB .Net does not support soapconnection class.

I did some tests and could find how to set the certificate.

I guess that you have already generated the proxy. In my case, I have of WS with a method

getGUID(). which returns a System.Guid

string ls_soapResponse

long   ll_result
PBWS.pbws_EmployeesServiceSoapClient  proxy_obj
proxy_obj = create PBWS.pbws_EmployeesServiceSoapClient
//----------------
PBWCF.WCFEndpointAddress ld_endpoint
ld_endpoint = create PBWCF.WCFEndpointAddress
ld_endpoint.URL = sle_url.text


try
      proxy_obj.wcfConnectionObject.EndpointAddress = ld_endpoint

     proxy_obj.wcfConnectionObject.ClientCredential.ClientCertificate.SubjectName = "c:\temp\mycert.cer"

     ls_soapResponse = proxy_obj.getGUID().ToString()
     mle_1.text = "SOAP Response : " + ls_soapResponse + "~r~n"
catch ( System.Net.WebException e )
     mle_1.text +=  "Error Cannot invoke Web service. Exception info: " + e.Message
end try

Hope this helps.

Abdallah.

Former Member
0 Kudos

I have tried and it still doesn't work same error unfortunately.Below i have uploaded a few images o show the code in debug mode after the error has occurred.

This is the exception i get

the certificate is set there so what am i missing?

this is the code for where i set the certificate

both CLientCredential areas of the connection object the certificate is set. I cant see what i am missing.

I noticed that within the m_service object the client certificate isnt set is this where i need to set it? Is it possible to access these "Non-public members" to do so?

I also noticed a few thing which are odd

  1. Any modification done within the code on deployment is not reflected in the .config file.
  2. Any modifications i make within the NVO which would be the proxy class are promptly removed upon build or deployment.
  3. Regardless of where i set the certificate in the code(outside of the NVO) that change is not reflected in the config file upon deployment
  4. Modifying the .config file has no effect whatsoever on the client application. So where is the program getting the configurations settings from? The error above i have replicated the exact same error on a working .NET client by removing the certificate details from the config file of that client
Former Member
0 Kudos

Hi Andre,

In my case, I give only the subjectName which is the full path to the certficate.

See this link :

ClientCertificateCredential Class

Regards.

Abdallah.