Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I hosted the WCF webservice in https:\\test.com:8080
Now i Want to test this Webservice in Console Appliction.
I got the Following Error

An unhandled exception of type 'System.Net.WebException' occurred in System.Web.Services.dll

Additional information: The request failed with HTTP status 401: Unauthorized.


My code is:


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using test1.ServiceReference1;
using test1.salesforce;
using System.Security.Cryptography.X509Certificates;
using System.ServiceProcess;
using System.Net;
namespace test1
{
    class Program
    {

        static void Main(string[] args)
        {
            System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();


        }
        public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
        {
            public TrustAllCertificatePolicy() {
                salesforce.Service1 sv = new salesforce.Service1();
                sv.GetAllData();
            }

            public bool CheckValidationResult(ServicePoint sp, X509Certificate cert, WebRequest req, int problem)
            {
                return true;
            }
        }

    }

}


Here Salesforce is my Web Reference.
Posted

Generally Authorization failure will come if you are using proxy. Try this links. Good luck

http://forums.asp.net/t/1635458.aspx?Pass+credential+to+Web+service+Soap+[^]
http://support.microsoft.com/kb/813834[^]
 
Share this answer
 
Comments
vinodhini sekar 28-Mar-14 5:38am    
Our username is sf\sfehfesr it get error
"Unrecognized escape sequence"
ArunRajendra 28-Mar-14 5:42am    
give it as "sf\\sfehfesr"
vinodhini sekar 28-Mar-14 6:10am    
I got the same error." The request failed with HTTP status 401: Unauthorized"
ArunRajendra 28-Mar-14 6:45am    
can you post the code?
In order to can test and HTTPS WCF service (does't matter the client type: console application, windows application, web application, etc.) you must have installed valid SSL certificates (could be also test certificated generated by you) on both computers: on client PC and on server PC (where your WCF service is installed).

So first you should create the SSL certificates then you should installed in both side, and finally you could test your WCF service. Here is a link that can help you in doing this: SSL with Self-hosted WCF Service[^]
 
Share this answer
 
v2

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