Skip to main content

Microsoft Silverlight

Unanswered Question Accessing WCF Service from Sharepoint 2007RSS Feed

(0)

Frank87
Frank87

Member

Member

5 points

59 Posts

Accessing WCF Service from Sharepoint 2007

 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 !!!

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Accessing WCF Service from Sharepoint 2007

 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

Mark as answer if this post answered your question.

Harsh Bardhan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Accessing WCF Service from Sharepoint 2007

 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."?

 

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Accessing WCF Service from Sharepoint 2007

 Hi,

You are trying to acess a service like this.

 Uri myUri = new Uri("http://localhost:81/wtv/Service1.svc"); 
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) 

Mark as answer if this post answered your question.

Harsh Bardhan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Accessing WCF Service from Sharepoint 2007

I use the this code:

  

Uri myUri = new Uri(Application.Current.Host.Source, "../Service1.svc");

 

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 ?

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Accessing WCF Service from Sharepoint 2007

 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..

 

 

 

Mark as answer if this post answered your question.

Harsh Bardhan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Accessing WCF Service from Sharepoint 2007

 Hi,

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()"

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Accessing WCF Service from Sharepoint 2007

 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.

Mark as answer if this post answered your question.

Harsh Bardhan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Accessing WCF Service from Sharepoint 2007

 Hi,

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! Sad

 

Do you think that your links fix my problem?

 

thanks!

 

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Accessing WCF Service from Sharepoint 2007

Hi,

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...

silverlight

 

 here is the direct link to my sirvices.....all works fine...

service 

 

 

 

 

 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...

sharepoint

 

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Accessing WCF Service from Sharepoint 2007

 Hi,

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.

 

Mark as answer if this post answered your question.

Harsh Bardhan

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Accessing WCF Service from Sharepoint 2007

 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

 

 

Frank87
Frank87

Member

Member

5 points

59 Posts

Re: Accessing WCF Service from Sharepoint 2007

On this link there is something like my solution....


http://img266.imageshack.us/img266/5488/solutionexplorerdd2.jpg


I'm going to explain the solution...

Silverlight Project:
It's my original application that works fine in stand-alone mode

Service Interface:
File added automatically when adding WCF Service.

Service:
My Silverlight application includes web service to connect to SQL Server DB

WebPart 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 sharepoint2007

using 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 project


So, 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
vaghelanik

Member

Member

2 points

1 Posts

Re: Re: Accessing WCF Service from Sharepoint 2007

Has anybody found solutions for this ? I am facing similar issue.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities