use web services in xbap application
-
Sunday, July 09, 2006 12:13 PM
i make simple web service that return string like this:
[
WebMethod] public string EmpDS() {return "hi man";}and i add my web service in my project like this
void Page_Load(object sender, EventArgs e){
localhost.
Service empser = new localhost.Service(); string str = empser.EmpDS();TextBox.Text = str;
}
in xaml code
<
Page x:Class="XEmployee.Employee" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Employee" Height="286" Width="473" Loaded="Page_Load">
<
Grid> </Grid></
Page>so when i run application this error appears:
System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
please help me i need it and i hope to send my an email with samples that solve this problem
awalaadin@hotmail.com
All Replies
-
Monday, July 10, 2006 1:44 PMXBAP applications can only make network connections to the location from which they were activated. At Tech-Ed '06 someone mentioned that there was a setting you could play with to get around that limitation when working on localhost, but I have yet to see a clear example of it in action.
-
Monday, July 10, 2006 2:43 PMModerator
If you have a web service running on your web/application server, you can just publish the XBAP to that server. That way both service and app are at the same site of origin (which is the restriction that Kevin refers to). In order to access 3rd party web services, I'd recommend creating a proxy service on your web server and connect from the app that way.
At Tech Ed, Karen and I had talked about elevating permissions outside of the sandbox within which XBAPs operate. That's kind of a cannon to swat a fly. I wouldn't recommend that approach unless you have no other options. Anyway, you'd do that by using the Trusted Application Deployment model in ClickOnce (where your end users install a certificate to their Trusted Publishers store; the same cert that the app was signed with). There are examples of this in the SDK and elsewhere on the web. I think this model breaks away from the spirit of XBAPs but exists for scenarios like a corporate intranet where the corporation or IT dept. exercises control over app deployments and can ensure the certs are installed. There is no native support for installation of those certs via the WPF deployment model. You'd probably have to roll your own MSI (again a departure from the XBAP deployment model).

