25
Views
2
Comments
Object reference not set to an object.... Using Web reference WSE 3.0 to call SOAP 
Question

Hi I'm creating an extension to call Soap web service.  I'm getting Object reference not set to an object of an instance error when finally calling the function in the web service.  Here is my code:

public void MssCheck(out string ssEcho) {

            // TODO: Write implementation for action

            ssEcho= null;

            GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Top 1", "check");                   //Inittialize the webservice object

            Kservice.Web.KWS kService = new Kservice.Web.KWS {

                    Url = "https://ws.k.com/ad/k.asmx",

                    Timeout = 3200000, 

            };

                //Create UsernameToken with user and password

                UsernameToken token = new UsernameToken("UserId", "password", PasswordOption.SendPlainText);

                GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Top 2", "check");

                //Add the token to the service

                kService.RequestSoapContext.Security.Tokens.Add(token);

                GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Top 3", "check");

                //Find the Certificate 

                X509SecurityToken securityToken = getSecurityToken("CertId");

                //Log the cert id and name to be sure I've got it.....

                GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, securityToken.Id + securityToken.Certificate.FriendlyName, "check");

                GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Top 4", "check");

                //Add the Certificate to the web service

                kService.RequestSoapContext.Security.Tokens.Add(securityToken);

                MessageSignature signature = new MessageSignature(securityToken);

                signature.SignatureOptions = SignatureOptions.IncludeSoapBody;

                kService.RequestSoapContext.Security.Elements.Add(signature);

                GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Top 5", "check");

                ssEcho = kService.Echo("Test");

                GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Top 6", "check");

}

I'm getting the Object reference error in this line:  ssEcho = kService.Echo("Test"); 

I'm using the exact same code (only getting the certificate in a different way) in another application and there everything is working fine.  I'm getting the right certificate I can see that in the Logs and the sercvice provider is not seeing anything call to the Echo function from me.

Any Ideas?

Rank: #390

Hi,

First of all you can consume a SOAP web service from outsystems it self. No extension required.

First try to create a individual dotnet application and consume the soap. Check if you r getting the same error, Then try to create the extension. Then easily you can debug and find out the issue,

Rank: #27477

Sourav Pasari wrote:

Hi,

First of all you can consume a SOAP web service from outsystems it self. No extension required.

First try to create a individual dotnet application and consume the soap. Check if you r getting the same error, Then try to create the extension. Then easily you can debug and find out the issue,

 Thanks for the response, yes I know I've tried that but that has not worked because of this error:  Certificate-based client authentication is not supported in TransportCredentialOnly security mode. Select the Transport security mode. 

And I've tried to change this Transport security mode but I'm still getting this Error.

There for I'm trying to create an Extension because I have the code that is working on another dot.net application.  So that has already been tested and everything is working fine on that application.  Almost same code, just the getSecurityToken function is different because on is getting from outsystems but the other from my machine.