Page view counter
Add web reference problem(silverlight 2.0) Subscribe to this thread
Last post 12-08-2008 4:22 AM by simbuaarumugam. 33 replies.
Sort Posts:
03-07-2008 9:39 AM
Add web reference problem(silverlight 2.0)

Hi! I have a problem
I build client server application on silverlight  2.0
I implement webService project - ChatService and asp.net project Chat.Display project
I need to use in Chat.Display the webService  ChatService
How can i add web reference to Chat.Display project?
I can just Add Service Link not Add web Reference?

Thanks 

Kostja

Loading...
Joined on 03-07-2008
Posts 16
03-07-2008 10:06 AM
Marked as Answer
Re: Add web reference problem(silverlight 2.0)

Use the "Add Service Reference" function, it does effectively the same thing as the old familiar "Add Web Reference" used to do for other project types. :)

Microsoft Xbox MVP

CraigN

Loading...
Joined on 05-11-2007
South Africa
Posts 89
03-07-2008 10:32 AM
Marked as Answer
Re: Add web reference problem(silverlight 2.0)

Understood
I add web service reference to my project

web service contain just one method

[WebMethod]
public string HelloWorld()
{
    return "Hello World";
}
 

Could you tell me or give me the code sample how to use this method from Page.xaml.cs code file please Smile

Thank you very much!
 

Kostja

Loading...
Joined on 03-07-2008
Posts 16
03-07-2008 11:06 AM
Marked as Answer
Re: Add web reference problem(silverlight 2.0)

 Assuming your Web service in your web project is named HelloWebService you'd do the following from your Silverlight Application project:

  1. Build the Web service project.
  2. Click "Add Service Reference".
  3. Click the Discover button and choose "Services in Solution".
  4. Select HelloWebService.asmx.
  5. Enter a Namespace, e.g. "Testing".
  6. Click OK.
  7. Goto your Page.xaml.cs file and add a using class for your namespace.
  8. In a method or even the constructor Page() enter: "HelloWebServiceSoapClient client = new HelloWebServiceSoapClient();"
  9. This will instantiate an instance of the proxy class.
  10. Next assign a callback event handler like this: "client.HelloWorldCompleted += HelloWorldCompletedEventArgs>(ClientHelloWorldCompleted);" Use the code generator helper for this. i.e. press TAB.
  11. Call the method asynchronously: "client.HelloWorldAsync();"
  12. Then in the ClientHelloWorldCompleted method inspect the e.Result.
Simple isn't it?

Microsoft Xbox MVP

CraigN

Loading...
Joined on 05-11-2007
South Africa
Posts 89
03-07-2008 11:30 AM
Marked as Answer
Re: Add web reference problem(silverlight 2.0)

Yes it simpleSmile
But i have some error 

 

An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code
Additional information: [UnexpectedHttpResponseCode]
Arguments:Not Found
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=UnexpectedHttpResponseCode

 

Code:

public Page()
        {
            InitializeComponent();


            ChatService.ChatSoapClient client = new Addition.Chat.Silverlight.ChatService.ChatSoapClient();           

            client.HelloWorldCompleted += new EventHandler<Addition.Chat.Silverlight.ChatService.HelloWorldCompletedEventArgs>(client_HelloWorldCompleted);
            client.HelloWorldAsync();
        }
        //----------------------------------------------------------------------------------------------------------------
        void client_HelloWorldCompleted(object sender, Addition.Chat.Silverlight.ChatService.HelloWorldCompletedEventArgs e)
        {
            String s = "";
        }

Do you have any idea?

Thanks
 

Kostja

Loading...
Joined on 03-07-2008
Posts 16
03-07-2008 11:44 AM
Marked as Answer
Re: Add web reference problem(silverlight 2.0)

That sounds like you are trying to call cross-domain. Create a clientaccesspolicy.xml file as per here (http://msdn2.microsoft.com/en-us/library/cc197955(VS.95).aspx) and put it in the root of the web site. Note this is not in the web service directory, but rather the root of the whole site. You should be able to access it using your web browser.

Does that solve the problem?
 

Microsoft Xbox MVP

CraigN

Loading...
Joined on 05-11-2007
South Africa
Posts 89
03-07-2008 12:10 PM
Re: Add web reference problem(silverlight 2.0)

 Thank you - it works

Kostja

Loading...
Joined on 03-07-2008
Posts 16
03-24-2008 7:47 AM
Re: Re: Add web reference problem(silverlight 2.0)

Its not working for me ........ following is the exception for..

 

An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code Additional information: [UnexpectedHttpResponseCode]Arguments:Not Found

Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=UnexpectedHttpResponseCode

 

bscc

Loading...
Joined on 03-24-2008
Posts 5
03-24-2008 9:54 AM
Re: Re: Add web reference problem(silverlight 2.0)

Please show your code

Kostja

Loading...
Joined on 03-07-2008
Posts 16
04-01-2008 9:28 PM
Re: Re: Re: Add web reference problem(silverlight 2.0)

I continually have the Arguments Not Found error and I have been working on it all day to no avail. Nothing seems to have an impact. i even built an application completely from scratch, all localhost, all defaults, and the same thing happens.

I am on IE7 and using VS2008 with Cassini for testing.

Web service call:

ServiceReference1.Service1SoapClient soap = new SilverlightApplication3.ServiceReference1.Service1SoapClient();soap.HelloWorldCompleted += new EventHandler<SilverlightApplication3.ServiceReference1.HelloWorldCompletedEventArgs>(soap_HelloWorldCompleted);

soap.HelloWorldAsync();

Web services are the default ASP.NET web services with Hello World.

That is the whole program. I am stumped. It sure seems like i am hitting a configuration issue somewhere.

wireplay

Loading...
Joined on 11-21-2007
Posts 20
04-01-2008 11:23 PM
Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

Ok, I pulled this completely out of Cassini and it worked. It didn't work when I tried it on 2 separate machines and I ran into the same error. I am going to put as much detail of this error here so it gets ht by the search engines and may help others.

Also, adding in a clientaccesspolicy.xml file into localhost route had no impact. However, I didn't investigate in detail how Cassini operates so I probably placed it in the wrong location. 

Basically, publish both the services website and the Silverlight website to IIS under localhost.

 

'e.Result' threw an exception of type 'System.Reflection.TargetInvocationException'

{System.ServiceModel.ProtocolException: [UnexpectedHttpResponseCode]
Arguments:Not Found
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=UnexpectedHttpResponseCode
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.Service1SoapClientChannel.EndHelloWorld(IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.SilverlightApplication3.ServiceReference1.Service1Soap.EndHelloWorld(IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.EndHelloWorld(IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.OnEndHelloWorld(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}

{System.ServiceModel.ProtocolException: [UnexpectedHttpResponseCode]
Arguments:Not Found
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=UnexpectedHttpResponseCode
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.Service1SoapClientChannel.EndHelloWorld(IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.SilverlightApplication3.ServiceReference1.Service1Soap.EndHelloWorld(IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.EndHelloWorld(IAsyncResult result)
   at SilverlightApplication3.ServiceReference1.Service1SoapClient.OnEndHelloWorld(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}

 

wireplay

Loading...
Joined on 11-21-2007
Posts 20
04-03-2008 6:58 AM
Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

Hi All,

I am still facing the same error even though i had use clientpolicy xml file and publish the website

any idea

Thanks & warm Regards
Ajay Gaikwad|Software Engineer
Accenture|Delivery Centers for Technology in India
Godrej&BoyceComplex,LBSMarg ,Vikroli(West)
ajay.gaikwad@accenture.com

Ajay Gaikwad

Loading...
Joined on 01-11-2008
Mumbai
Posts 30
04-17-2008 5:42 AM
Re: Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

Hi,

i tried using add service reference instead of add web reference.

after i added that web service, in intellicence, it should show me the list of webmethods. its actually showing the methods but with "async " postfix.

is  it because these web methods are talking to backend data base? because this is only the case with methods returning some value, other void methods are perfectly working!!!

needed help immedtley.

Thanks,

Lakshmi

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-17-2008 6:36 AM
Re: Re: Add web reference problem(silverlight 2.0)

hi, i have created a silver light UI.

There is a login page, which authenticates the user using a webmethod

Authenticate(uname, pwd); which returs "usercontext" data object.but after i refered the webservice which contains this method, it just shows void as return type. not usercontext. why is it happening?

 

 

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-17-2008 8:45 AM
Re: Re: Add web reference problem(silverlight 2.0)

Could you show your code?

Kostja

Loading...
Joined on 03-07-2008
Posts 16
04-18-2008 6:53 AM
Re: Re: Add web reference problem(silverlight 2.0)

Hey thanks for the quick reply.. it was least expected.. actually :) 

 the code is below:

 

public
Page()

{

InitializeComponent();

}

private void UserControl_Loaded(object sender, RoutedEventArgs e)

{

 

rotateEllipse1.Begin();

rotateEllipse1.Stop();

 

rotateEllipse2.Begin();

rotateEllipse2.Stop();

 

rotateEllipse3.Begin();

rotateEllipse3.Stop();

 

rotateEllipse4.Begin();

rotateEllipse4.Stop();

 

}

public void validateUser(object sender, RoutedEventArgs e)

{

RES_ServiceSoapClient service = new RES_ServiceSoapClient();UserContext userContextData = new UserContext();

userContextData = service.AuthenticateAsync(user.Text, password.Text);

string role = GetPrimaryRole(userContextData);

if (role.ToUpper() == "HR")

{

TransitionBase transition = new FadeTransition();NavigationHelper.Navigate(transition, new SearchPage());

}

 

Here the method 'Authenticate' takes two parameters username, and password,and it is supposed to return "usercontext" which is a Dataobject.

but the problems i am facing here is,

1. in the intellicense i'm not getting 'Authenticate", but 'AuthenticateAsync" instead.

2.and its showing return type of the method as void(it should show "usercontext" instead.)

 

 

 

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-18-2008 7:09 AM
Re: Re: Add web reference problem(silverlight 2.0)

 Hello, you can't use "Authenticate" directly. Everything in Silverlight are in async-mode. Not sync-mode.

You have to use async-mode like below.

For example:

{

WebServiceProxy.ProductManagerSoapClient productMgrSoapClient = new SL2WebSrv.WebServiceProxy.ProductManagerSoapClient();

productMgrSoapClient.RetrieveProductsAsync();
productMgrSoapClient.RetrieveProductsCompleted +=
new EventHandler<SL2WebSrv.WebServiceProxy.RetrieveProductsCompletedEventArgs>(productMgrSoapClient_RetrieveProductsCompleted);

}

void productMgrSoapClient_RetrieveProductsCompleted(object sender, SL2WebSrv.WebServiceProxy.RetrieveProductsCompletedEventArgs e) {
if (e.Error == null)
   displayData(e.Result);
}
 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Microsoft WPF & Silverlight Insider
Blog : http://michaelsync.net


mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,478
04-18-2008 7:48 AM
Re: Re: Add web reference problem(silverlight 2.0)

Try to use code bellow

 It needs to replace {Service namespace }

private RES_ServiceSoapClient service;

public Page()
{
      InitializeComponent();
      service =
new RES_ServiceSoapClient();
      service.AuthenticateCompleted += new EventHandler<{Service namespace }.AuthenticateCompletedEventArgs>(Service_AuthenticateCompleted);

private void Service_AuthenticateCompleted(object sender, {Service namespace }.AuthenticateCompletedEventArgs e)
{

    if(null == e.Error)
    {

          RES_ServiceSoapClient UserContext userContextData = new UserContext();
          userContextData = e.Result;        

          string role = GetPrimaryRole(userContextData);

          if (role.ToUpper() == "HR")

          {

               TransitionBase transition = new FadeTransition();NavigationHelper.Navigate(transition, new SearchPage());

          }
}

 

public void validateUser(object sender, RoutedEventArgs e)

{
    service.AuthenticateAsync(user.Text, password.Text);
}

 

Smile 

Kostja

Loading...
Joined on 03-07-2008
Posts 16
04-18-2008 8:31 AM
Re: Re: Re: Add web reference problem(silverlight 2.0)

Heyyyy, ! its built successfully with out any error, thanks a lot... :)

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-18-2008 8:35 AM
Re: Re: Re: Add web reference problem(silverlight 2.0)

You are welcome - Please,Mark as Answer

Kostja

Loading...
Joined on 03-07-2008
Posts 16
04-18-2008 1:47 PM
Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

m sorry to ask a stupid doubt, but how to mark it as an answer, i cudnt find that option anywhere!

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-19-2008 12:40 PM
Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

lakshmi krishna:
m sorry to ask a stupid doubt, but how to mark it as an answer, i cudnt find that option anywhere!
 

No. You can't. Only the original poster can mark it as an answer.  I'm not sure why the team of this forum uses that way.....

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Microsoft WPF & Silverlight Insider
Blog : http://michaelsync.net


mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,478
04-21-2008 1:33 AM
Re: Re: Add web reference problem(silverlight 2.0)

Hi,  

i am able to build the solution, but once the user name n password is entered, its giving the below error. 

An exception of type 'System.ServiceModel.CommunicationException' occurred in System.ServiceModel.dll but was not handled in user code

Additional information: [CrossDomainError]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.2&File=System.ServiceModel.dll&Key=CrossDomainError

(PLS. Do let me know how to mark a post as answered !! )

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-21-2008 7:23 AM
Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

hey even u have written - ( If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

could anyone please tell me how do i "mark a post as answer" ???, is there a hyper link or button by name "mark as answer" ?

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-21-2008 10:18 AM
Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

lakshmi krishna:
hey even u have written - ( If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)
 

It's my signature, man. :)

As I said in my previous thread, only original poster can mark it as an answer.. So, it won't be possible for you to do.

 

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Microsoft WPF & Silverlight Insider
Blog : http://michaelsync.net


mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,478
04-21-2008 11:01 AM
Re: Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

oops! ok... i got it :)

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-22-2008 1:46 AM
Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

Hi, 

i am getting this error , i have been trying to fix this from many days.

An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code

Additional information: The remote server returned an unexpected response: (404) Not Found.

after i edited the manifest, i am able to view the exception in detail!. as shown below. even after including clientaccesspolicy.xml and crossdomain.xml files.

An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code

Additional information: The remote server returned an unexpected response: (404) Not Found.

could anyone tell me the solution for this


 

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
04-25-2008 1:33 AM
Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

Hi  lakshmi

Are you trying to use you WCF service using IIS.if so then please add .SVC extension from confirgution option of property of your virtual directory.Error may occur due to access problem. your silverlight desktop apll will not understand where the service is avaiable. can you please check the address of your service in webconf file in web app and service confirgution file it should be same. please let me know if you need more clarifcation on same.

 

Thanks & warm Regards
Ajay Gaikwad|Software Engineer
Accenture|Delivery Centers for Technology in India
Godrej&BoyceComplex,LBSMarg ,Vikroli(West)
ajay.gaikwad@accenture.com

Ajay Gaikwad

Loading...
Joined on 01-11-2008
Mumbai
Posts 30
04-25-2008 11:06 AM
Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

Hi Ajay,

Thanks. Actually i found the solution.

I am using a simple asmx service. I created one more service in the same domain as of the Application to access the cross domain service,now its workin perfectly..

lakshmi krishna

Loading...
Joined on 04-10-2008
bangalore
Posts 21
05-10-2008 6:46 AM
Re: Add web reference problem(silverlight 2.0)

Hi,

iam getting the same error wha tu mentioned in this thread

"An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code".

i read the answer what u ahve given but iam not able to understand properly.

How to add "clientaccesspolicy.xml " ,and where to add???????

i have one silverlightApplication,one webservice.

iam calling webservice in silverlgiht applciation by using service reference.

and i have written the code in xaml.cs to call the web service.

iam not understanding what is the root ?where to add the "clientaccesspolicy.xml"?

iam calling webservice in the silverlgiht application ,so silverlgiht application becames the host of the webservice,Right????????

so that i added this "clientaccesspolicy.xml" in the silverlgiht applciation.

plese reply me ASAP.

 

Thanks & Regards

Deepika

 

deepikaFO

Loading...
Joined on 04-25-2008
Posts 7
05-10-2008 12:19 PM
Re: Add web reference problem(silverlight 2.0)

I suppose your solution has 3 projects - the Silverlight application, the web app that hosts the Silverlight project and the Web service project, right? Your policy file should be added to the root of the third project. You can copy it next to the .svc file.

However, if you are only consuming an external service over which you have no control over, you can only hope that the provider of the service has the policy file in place.

Cross domain access without the policy file is forbidden in Silverlight to avoid cross site forgery. Read this MSDN article and three part article by Karen Corby starting here.

Hope this helps,
Jim (http://jimmangaly.blogspot.com/)

Please MARK the replies as answers if they answered your question

http://www.identitymine.com/

Jim Mangaly

Loading...
Joined on 04-21-2008
Kochi, India
Posts 378
06-06-2008 8:16 AM
Re: Add web reference problem(silverlight 2.0)

Please can u tell me how to add a refernce to the MSn Search lnk in a silverlight application

I want to add a refernce to the following link: http://soap.search.msn.com/webservices.asmx?wsdl 

its very urgent.

amurawat@hotmail.com

Loading...
Joined on 06-06-2008
Posts 6
12-08-2008 4:07 AM
Re: Re: Add web reference problem(silverlight 2.0)

 Hi amur

You just download the file what you want to add the reference in to your project like (.dll) files . and the open your project in your project silvelright references is there .Just right click on that give add references .then click the Browse button and add the referece where you save the download file 

SimbuAarumugam India
http://simbusoftwareengineer.blogspot.com
(Mark As Answer If its Satisfy your needs)

simbuaarumugam

Loading...
Joined on 07-22-2008
India-Chennai
Posts 405
12-08-2008 4:22 AM
Re: Re: Re: Re: Re: Re: Add web reference problem(silverlight 2.0)

 hi lakshmi

Did you use LINQ in your project .. please update the service reference in your project or delete and re add your service references .. this is a problem for generating the error The remote server returned an unexpected response: (404) Not Found.   Check it correctly 

SimbuAarumugam India
http://simbusoftwareengineer.blogspot.com
(Mark As Answer If its Satisfy your needs)

simbuaarumugam

Loading...
Joined on 07-22-2008
India-Chennai
Posts 405
Microsoft Communities