1

Want to call WCF service from Sharepoint 2013 Visual Web Part; when using this Service from Console it works perfectly.

I receive following Security Exception when using svc from webpart:

Request for the permission of type 'System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I´ve checked Sharepoint web.config file:

trust level="Full"  label -> Ok.

Web part Added to safe Controls -> Ok.

Add safe control in package configuration -> Ok.

What am i missing?

This is my code:

                using (Service1Client svc = new Service1Client(new BasicHttpBinding(),
                new EndpointAddress(new Uri("http://xxxxxxxx/Service1.svc"))))
            {

                svc.ClientCredentials.Windows.ClientCredential.Domain = "domain";
                svc.ClientCredentials.Windows.ClientCredential.UserName = "user";
                svc.ClientCredentials.Windows.ClientCredential.Password = "pass";

                Label1.Text = svc.GetData(123456); 
            }

I´m thinking about using JS and ajax to do the same. It is necessary to use a Full-trusted proxy for this?

Regards,

0

Sandbox Solutions are restricted from making calls to external web services. You could create a full-trust proxy or you could call the service from the client-side. If you choose client-side then you are going to need to use some kind of library (WebProxy, CORS) to get around the cross-domain restrictions enforced by the browser.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.