cancel
Showing results for 
Search instead for 
Did you mean: 

PowerBuilder 12.6 will support Web Service Security on SoapConnection

Former Member
0 Kudos

Hi ,

I just came cross the situation where we need to include the WebService Security (Wsse) on soap header to authenticate against the web service. But in the PowerBuilder 12.6 Classic SoapConnection object doesn't have any method to support this feature to include in Soapheader.

Anyone guide how to implement this token based authentication in the PowerBuilder 12.6 Classic. Greatly Appreciate you support.

If there is no option, then we have to PowerBuilder.NET WCF assembly

Thanks,

Balu

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Is there anyway to open defect to address this issue in future release?

Former Member
0 Kudos

Finally I found solution for this.. I create my own proxy class using NVO and implement the reference proxy dll using PBWCF class..

It is working... Sample. Hope this will help our community when they have this kind of issue in PB.NET


Declaration :  in NVO.

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

// General public variables

public PBWCF.WCFConnection   wcfConnectionObject


// General private variables

private integer   m_revision


private Sybase.PowerBuilder.WCFRuntime.Service   m_service

public Sybase.PowerBuilder.WCFRuntime.PBWSEUserNameTokenHeader m_tokenheader


public PBWCF.WCFSoapMessageHeader wcfsoapheaderobject

Constructor : of NVO

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

    m_service = create Sybase.PowerBuilder.WCFRuntime.Service

    // Revision Number
    m_revision = 1
    m_service.setRevision(m_revision)

    // Assembly name
    m_service.setAssemblyName("n_sso_proxy.dll")
    // Class name
    m_service.setClassName("n_sso_proxy.SSOLoginPortClient")
    // Prefix
    m_service.setPrefix("")

    wcfConnectionObject = create PBWCF.WCFConnection

    // EndpointAddress
    PBWCF.WCFEndpointAddress d_endpoint
    d_endpoint = create PBWCF.WCFEndpointAddress
    d_endpoint.URL = "Endpoint URL "
    wcfConnectionObject.EndpointAddress = d_endpoint

   
// BindingType
    wcfConnectionObject.BindingType = PBWCF.WCFBindingType.BasicHttpBinding!

PBWCF.WCFBasicHttpBinding d_binding
    d_binding= Create PBWCF.WCFBasicHttpBinding


    d_binding.TransferMode = PBWCF.WSTransferMode.BUFFERED!
    d_binding.MessageEncoding = PBWCF.WSMessageEncoding.TEXT!
    d_binding.TextEncoding = PBWCF.WSTextEncoding.UTF8!
d_binding.HostNameComparisonMode = PBWCF.WCFHostNameComparisonMode.STRONGWILDCARD!

    d_binding.MaxBufferPoolSize = 524288
    d_binding.MaxBufferSize = 65536
    d_binding.MaxReceivedMessageSize = 65536
    d_binding.AllowCookies = false
    //d_binding.BypassProxyOnLocal = false

    // ReaderQuotas
    d_binding.ReaderQuotas = Create PBWCF.WCFReaderQuotas
    d_binding.ReaderQuotas.MaxArrayLength = 131072
    d_binding.ReaderQuotas.MaxBytesPerRead = 32768
    d_binding.ReaderQuotas.MaxDepth = 32
    d_binding.ReaderQuotas.MaxNameTableCharCount = 131072
    d_binding.ReaderQuotas.MaxStringContentLength = 65536
d_binding.BypassProxyOnLocal = true

    // Security
d_binding.Security = Create PBWCF.BasicHttpSecurity
    d_binding.Security.SecurityMode = PBWCF.BasicHttpSecurityMode.TRANSPORTCREDENTIALONLY!
//d_binding.Security.Message.ClientCredentialType =PBWCF.BasicHttpMessageCredentialType.USERNAME!
// Transport Security
    d_binding.Security.Transport.ClientCredentialType = PBWCF.HttpClientCredentialType.BASIC!
d_binding.Security.Transport.Realm = ""
//d_binding.Security.SecurityMode = PBWCF.BasicHttpSecurityMode.MESSAGE!
//d_binding.Security.Message.ClientCredentialType = PBWCF.BasicHttpMessageCredentialType.USERNAME!
//d_binding.Security.Message.SecurityAlgorithm = PBWCF.SecurityAlgorithmType.DEFAULT!

wcfsoapheaderobject = create PBWCF.WCFSoapMessageHeader
wcfsoapheaderobject.AddWSEUserNameToken( "UserName", "Passowrd")
 
wcfConnectionObject.SoapMessageHeader = wcfsoapheaderobject
wcfConnectionObject.BasicHttpBinding = d_binding

    // Proxy Security
    wcfConnectionObject.ProxyServer.CredentialType = PBWCF.HttpProxyCredentialType.BASIC! 
    wcfConnectionObject.ProxyServer.UseDefaultWebProxy = true


    m_service.setConnectionOption(wcfConnectionObject)

Destructor : of NVO

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


destroy wcfsoapheaderobject

destroy wcfConnectionObject

destroy m_service

Function to Call Method WS method:

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

    String ls_str
//n_sso_proxy.loginRequest request

// Set Connection Object
    m_service.setConnectionOption(wcfConnectionObject)

    // Set Method
    m_service.setMethodName("login")

    // Pass Arguments
    m_service.removeAllArguments()
    //m_service.addArgument(request, "n_sso_proxy.login", false, false)
   
    // Set Return Type
    m_service.setReturnType("string")
  
    // Invoke the Service
    m_service.Invoke()

    // Get Return Value
    //n_sso_proxy.loginResponse svcReturnValue

    ls_str = m_service.getReturnValue().ToString()
     return ls_str

Calling Method in WCF client

WS_Call.n_sso_proxy svc
svc = create WS_Call.n_sso_proxy

  
try
 
   svc.wcfConnectionObject.ClientCredential.UserName.Domain = "XXX"
   svc.wcfConnectionObject.ClientCredential.UserName.UserName="UserName"
   svc.wcfConnectionObject.ClientCredential.UserName.Password="Password"
  
   st_1.Text = svc.login() 
    
Catch (System.Exception ee)
st_1.Text = string(ee.GetBaseException() )
End try

Thanks all for giving suggestions. Appreciated!

Answers (4)

Answers (4)

0 Kudos

Hi Bala,

Need your help to know, how Single sing on can be implemented in PowerBuilder(12.5) application. How to authenticate a user using Active directory?

Please, Email me the steps on sourabhjn15@gmail.com.

Thanks,

Sourabh

Former Member
0 Kudos

Hope you are asking on PowerBuilder 12.5 Classic version.

1. Create the Proxy Object for the LDAP WSDL using Powerbuilder Proxy Generator Project use .Net engine method while building the proxy, because it gives some additional method for invoking the service.

2. Import the PowerBuilder .net soap objects extension from the shared folder.

3. Create a nvo object to create soap connection and initiated the soap connect with Proxy URL.

4. Call the respective method by passing usename and password and get authenticated.

5. Since you are using single sign on with Active Directory, you need to create a common id to connect the database and make sure you are encryting password in the application. We can't hard code the password in the application, since on PBD also you can view the password.

6. Authenticate against the LDAP and once it is authenticated use the common id to connect the database.

If you have any specific question, please let me know

0 Kudos

Hi Balu,

Thanks for your reply.

Could you please share your email id so I can send you the steps I am following.

Thanks

Sourabh

Former Member
0 Kudos

This message was moderated.

0 Kudos

Hi Balu,

I am able to call the webservice but I am getting message 'No security header in message but required by policy'. Looks like It is expecting a header to be passed in request. Could you please let me know how to create an header and pass it in request.

Former Member
0 Kudos

I think you have to build your WS proxy using wsewsdl3.exe (is part of Microsoft WSE: Download Web Services Enhancements (WSE) 3.0 for Microsoft .NET from Official Microsoft Download Cen...).

So you can't build it with PB.NET.

Once you have an assembly with the proxy you can call that from Classic using a COM Callable Wrapper.

former_member190719
Active Contributor
0 Kudos

PB.Net uses WCF which is*newer* technology than WSE.  WSE is still based on ASP.Net web services.   PB.Net can create the proxy using WCF.  PB Classic can't because it's using ASP.Net web services without WSE.

Former Member
0 Kudos

My issue is PB.NET 12.6 is not generating the proxy using WCF. that is the reason I am asking this questions.

It is throwing below exception when I try to generate proxy.

Exception: Object reference not set to an instance of an object.

former_member190719
Active Contributor
0 Kudos

Unless you have expose the service so we can try to hit it or give us the actual WSDL I'm afraid there's not much we can do to help.

Former Member
0 Kudos

- I would try to create your call in Visual Studio/C#.

- Compile your project as an C# Library with the ComVisible flag.

- Use your library in your PB application.

Using .NET class with PowerBuilder 12.5 Classic (version ...

Former Member
0 Kudos

Hi Ben;

  For the interim I think that your suggestion is the best. I'm not hopeful that PB.Net based on VS 2010 is now robust enough to build leading edge web services. The other aspect that's getting  my spidey senses tingling is if the PB.Net IDE will even continue.

Regards .. Chris

former_member190719
Active Contributor
0 Kudos


If there is no option, then we have to PowerBuilder.NET WCF assembly

That's basically your only option.

Once you've created a proxy in PB.Net you can call that from Classic using a COM Callable Wrapper.

Former Member
0 Kudos

When try to generate the WCF proxy client I am getting the below error.. Could anyone you faced this issue ?

Exception: Object reference not set to an instance of an object.

Because of this proxy class is not generating in the PB.NET. I am using PB 12.6. Net

-------- Generate WCF proxy objects --------


Using Project p_wcfclient


Validating project properties...


Generating WCF client assembly: C:\PB_WORK-12.6\PBL12_Local\WebService_test_PBNET\n_nvo_proxy.dll


Using WSDL: http://spsoa-uat01v:21111/sst/runtime.asvc/com.actional.intermediary.Access_Manager_Token_Service.Ac...


Loading WCF client assembly: c:\pb_work-12.6\pbl12_local\webservice_test_pbnet\n_nvo_proxy.dll...


1 Services Added.   4 DataClasses Added.


Unloading Assembly.


Loading WCF client assembly: C:\PB_WORK-12.6\PBL12_Local\WebService_test_PBNET\n_nvo_proxy.dll...


Deleting 0 existing proxy objects in proxy.pbl (C:\PB_WORK-12.6\PBL12_Local\WebService_test_PBNET)...


0 proxy objects deleted.


Generating proxy object code in proxy.pbl (C:\PB_WORK-12.6\PBL12_Local\WebService_test_PBNET)...


Exception: Object reference not set to an instance of an object.


Unloading Assembly.


-------- WCF proxy generation finished --------


former_member190719
Active Contributor
0 Kudos

Can you verify with something like SoapUI that the service is working?

Former Member
0 Kudos

Service is working in SOAP UI and no issues...