Skip to main content
Home Forums Silverlight Programming Accessing Web Services with Silverlight Accessing WCF Service from Sharepoint 2007
13 replies. Latest Post by vaghelanik on August 26, 2009.
(0)
Frank87
Member
5 points
59 Posts
02-03-2009 5:53 AM |
I have silverlight web app with a web service. This web service connects to a SQL db. Running the app in stand-alone all works fine, but when I put my silverlight application into sharepoint(by adding a webpar), the web service can't be found....on the pop up the error is
Unhandled Error in Silverlight6 Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
.To load the service in the xaml.cs page I used this code:
Uri myUri = new Uri(Application.Current.Host.Source, "../Service1.svc");
I've also tried with this one:
Uri myUri = new Uri("http://localhost:81/wtv/Service1.svc");
but it doesn't work again...
I've deleted and added again the service reference, but the problem is still the same...
Does anyone know how can I fix this problem ?? It's very important !!!
HarshBar...
Star
9908 points
1,719 Posts
02-03-2009 7:21 AM |
Hi,
You Need to Add Service Reference.
You are trying to acess that service Directly.
Check these links.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=228
http://www.dotnetcurry.com/ShowArticle.aspx?ID=208
02-03-2009 8:36 AM |
If I run my application on my website all works fine, the problem is that it doesn't work when I run it in sharepoint, using the webpart.
The Service Reference seems ok, since the appl works on the browser, isn't it ?
what does it mean "You are trying to acess that service Directly."?
02-03-2009 9:29 AM |
You are trying to acess a service like this.
Are you adding a reference of this service??
In your local system are you able to consume Service in desired way??(as you mentioned above it is working fine)
02-03-2009 9:56 AM |
I use the this code:
Yes, I've added the service reference.
Yes, I'm able to consume the service via web, but when I add my silverlight app in sharepoint (using webpart) the service throws exception. How can I consume this service through sharepoint ?
02-03-2009 10:01 AM |
What do you mean by web??
Do you mean consuming by typing http://-------/Service1.svc in your browser and acessing that.??
Can you tell what is error message.if you can paste it here it will be easy to find..
02-03-2009 10:45 AM |
yes "via web" I mean Http://myserver/services.svc and works fine, this service connects to SQL db and populate a drop down list,
The services stops work when I deploly my silverlight app in sharepoint, on bottom-left o my browser the error is
"Unhandled Error in Silverlight6 Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()"
02-03-2009 10:53 AM |
Hi Frank.
the way by which you are trying to acess is not looking correct to you.
In my first post i have mentioned few url.
Please go through that.
02-03-2009 11:10 AM |
I have checked your urls, but it seems to me that they are about using WCF in Silverlight.
I don't know If the problem is inside WCF services itselfs (anyway stand-alone works fine) or the problem is something missing configuration for sharepoint....... I'm going crazy!
Do you think that your links fix my problem?
thanks!
02-04-2009 9:18 AM |
I've made some screenshot that describes my problem....
I've followed the examples in the urls...... anyway the steps are the same that I followed to create my web service....
Here there is the silverlgiht application with the services.... published on web server...all works fine...
here is the direct link to my sirvices.....all works fine...
here is shar point site....on my IIS...on a different port (80)...the SVC file path is different....sharepoint can't find the service in my application the code to lace the service is
Uri myUri = new Uri ( Application .Current.Host.Source, "../Service1.svc");
I don't know where to put my service to make it visible from sharepoint...
02-04-2009 9:30 AM |
Your Screen shots are not visible at all at my end.
Can you Give Service URl.
Apart From that Can you Place a client Acess Policy File at that Url so i can create a Sample Kind Of Stuff and Can send you.
02-04-2009 9:53 AM |
sorry....here is the images
http://img17.imageshack.us/img17/9708/silverlightappjc4.jpg
http://img18.imageshack.us/img18/8651/serviceviawebrn7.jpg
http://img18.imageshack.us/img18/6358/sharepointgl0.jpg
02-09-2009 5:26 AM |
On this link there is something like my solution....http://img266.imageshack.us/img266/5488/solutionexplorerdd2.jpgI'm going to explain the solution...Silverlight Project:It's my original application that works fine in stand-alone modeService Interface:File added automatically when adding WCF Service.Service:My Silverlight application includes web service to connect to SQL Server DBWebPart Project:My Silverlight application must runs under sharepoint2007.....so I added to my Silverlight Project a WebPartProject.In WebPartWebTV.cs I used this code to include silverlight file (file.xap) under sharepoint2007using System; using System.Runtime.InteropServices; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Serialization; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.WebPartPages; namespace MyWebPart { [Guid ( "3b0db252-9df2-4aef-b391-a97f1e4839af" )] public class MyWebPart: System.Web.UI.WebControls.WebParts. WebPart { System.Web.UI.SilverlightControls. Silverlight ctrl = null ; public MyWebPart() { } protected override void OnLoad( EventArgs e) { base .OnLoad(e); ScriptManager sm = ScriptManager .GetCurrent( this .Page); if (sm == null ) { sm = new ScriptManager (); Controls.AddAt(0, sm); } } protected override void CreateChildControls() { //base.CreateChildControls(); ctrl = new System.Web.UI.SilverlightControls. Silverlight (); ctrl.ID = "MyWebPart"; ctrl.Source = "~/bin/player.xap"; ctrl.Width = new Unit (800); ctrl.Height = new Unit (600); Controls.Add(ctrl); } public override void RenderControl( HtmlTextWriter writer) { ctrl.RenderControl(writer); } } } I can see the silverlight application in webpart...but the serivce Service1.svc is unaccessible, so my app doesn't work correctly.New Service already added:I've followed some examples that works with Web Services under sharepoint by adding the svc file (share point template) direclty in web part projectSo, in conclusion, Does my service (Service1.svc....originally included under silverlight project) must be moved under WebPartProject to be consumed by sharepoint ?thank you for your help !
vaghelanik
2 points
1 Posts
08-26-2009 10:49 AM |
Has anybody found solutions for this ? I am facing similar issue.