Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm new in consuming web services and i have to access a state-run web service.
I was given an app.config file, a certificate file (.cer) and some general instructions.

Haven'n used Visual Studio 2008 Express before but i have 15 years experience in writing vb5/6 code.

Anyway, I installed the .cer file using mmc and then opened a new project and
I added the System.Runtime.Serialization and System.ServiceModel
I addedd a service reference to the WSDL link
I included app.config file in my project
and wrote the follwing code.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EchoSvcClientConsAppl
{
    class Program
    {
        static void Main(string[] args)
        {

            ConAp66.myserviceref.ServiceClient clientProxy = new ConAp66.myserviceref.ServiceClient();

            clientProxy.ClientCredentials.UserName.UserName = "xx";
            clientProxy.ClientCredentials.UserName.Password = "xx";

            clientProxy.Open();

            String ar1 = "xxx";
            String ar2 = "xxx";
            String ar3 = "xxx";
            ConAp66.myserviceref.eRes r = clientProxy.getRes1(ar1, ar2, ar3);

            clientProxy.Close();

            System.Console.ReadLine();
        }
    }
}


i get an error on line:
ConAp66.myserviceref.eRes r = clientProxy.getRes1(ar1, ar2, ar3);

saying that i have token authentication problems

any clues???
Your help would be greatly appreciated since i really don't know what to do...
Posted
Updated 18-Aug-13 20:04pm
v6
Comments
ZurdoDev 14-Aug-13 8:17am    
Yes, you need to authenticate properly. You'll have to check with whoever built the webservice.
niyo66 14-Aug-13 15:41pm    
i'm a newbe in consuming web services and maybe i'm doing something wrong.

The owner of the web service provided a .cer file and an app.config file,
so i included the app.config in my project and also installed the .cer file using mmc console.

should i do something more???

i've tried evereything...
ZurdoDev 15-Aug-13 15:08pm    
You'll likely have to attach the certificate in code. Search on c# x.509 certificates and you'll see examples.
niyo66 15-Aug-13 15:47pm    
I was also given a .jks file, is there anything i should do with this one?
ZurdoDev 15-Aug-13 15:49pm    
I'm not sure. In the past when I did x509 certs I never had one.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900