Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

PowerBuilder 12.6 will support Web Service Security on SoapConnection

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

Former Member
Former Member replied

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!

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question