Problem with web service call  
Author Message
Pao.lino





PostPosted: ASMX Web Services and XML Serialization, Problem with web service call Top

I developed a web application (code behind C#) for calling a web service.

The first call is for the autentication on the web service by login and password. I do this call with:

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(getloginUrl())

getLoginUrl() simply return the web service url (https://xxx.yyyy.com/zzzz/Integration command=login)

Until I worked on my machine...no problem; the web service calls work perfectly. As soon as I put my web application on my hosting provider and I test the application by IE I got this error:


System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean i****Set) at System.Security.CodeAcces****ission.Demand() at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) at System.Net.HttpRequestCreator.Create(Uri Uri) at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) at System.Net.WebRequest.Create(String requestUriString) at Ses.WebService.Handler.Communication.Login(String userName, String password) in d:\inetpub\webs\paolinotestdotnet1arubait\App_Code\Communication.cs:line 31 at _Default.cmdLogin_Click(Object sender, EventArgs e) in d:\inetpub\webs\paolinotestdotnet1arubait\Default.aspx.cs:line 43 The action that failed was: Demand The type of the first permission that failed was: System.Net.WebPermission The Zone of the assembly that failed was: MyComputer

I think that's a permission problem....but I really don't know how I have to do to solve that!!!

Please, someone could help me !!

Thanks




.NET Development6  
 
 
Dennis Stone - MSFT





PostPosted: ASMX Web Services and XML Serialization, Problem with web service call Top

It sounds like your hosting provider is using a medium trust policy. Here's a listing of the restrictions this will cause from msdn:

The main constraints placed on medium trust Web applications are:

  • OleDbPermission is not available. This means you cannot use the ADO.NET managed OLE DB data provider to access databases. However, you can use the managed SQL Server provider to access SQL Server databases.
  • EventLogPermission is not available. This means you cannot access the Windows event log.
  • ReflectionPermission is not available. This means you cannot use reflection.
  • RegistryPermission is not available. This means you cannot access the registry.
  • WebPermission is restricted. This means your application can only communicate with an address or range of addresses that you define in the <trust> element.
  • FileIOPermission is restricted. This means you can only access files in your application's virtual directory hierarchy. Your application is granted Read, Write, Append, and PathDiscovery permissions for your application's virtual directory hierarchy.

Here's a link to the full article, it should be helpful in figuring out if this is indeed your problem and what you may be able to do about it.

http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnpag2/html/paght000020.asp