Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Add web reference problem(silverlight 2.0)
34 replies. Latest Post by kwells5750 on September 30, 2009.
(1)
Kostja
Member
38 points
16 Posts
03-07-2008 9:39 AM |
Hi! I have a problemI build client server application on silverlight 2.0I implement webService project - ChatService and asp.net project Chat.Display projectI need to use in Chat.Display the webService ChatServiceHow can i add web reference to Chat.Display project?I can just Add Service Link not Add web Reference?
Thanks
CraigN
352 points
89 Posts
03-07-2008 10:06 AM |
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. :)
03-07-2008 10:32 AM |
UnderstoodI 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
Thank you very much!
03-07-2008 11:06 AM |
Assuming your Web service in your web project is named HelloWebService you'd do the following from your Silverlight Application project:
03-07-2008 11:30 AM |
Yes it simpleBut i have some error
An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user codeAdditional information: [UnexpectedHttpResponseCode]Arguments:Not FoundDebugging 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?
03-07-2008 11:44 AM |
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?
03-07-2008 12:10 PM |
Thank you - it works
bscc
6 points
5 Posts
03-24-2008 7:47 AM |
Its not working for me ........ following is the exception for..
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
03-24-2008 9:54 AM |
Please show your code
wireplay
44 points
20 Posts
04-01-2008 9:28 PM |
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:
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.
04-01-2008 11:23 PM |
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 FoundDebugging 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)}
Ajay Gai...
30 Posts
04-03-2008 6:58 AM |
Hi All,
I am still facing the same error even though i had use clientpolicy xml file and publish the website
any idea
lakshmi ...
42 points
21 Posts
04-17-2008 5:42 AM |
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
04-17-2008 6:36 AM |
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?
04-17-2008 8:45 AM |
Could you show your code?
04-18-2008 6:53 AM |
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);
Hey thanks for the quick reply.. it was least expected.. actually :)
the code is below:
{
InitializeComponent();
}
rotateEllipse1.Begin();
rotateEllipse1.Stop();
rotateEllipse2.Begin();
rotateEllipse2.Stop();
rotateEllipse3.Begin();
rotateEllipse3.Stop();
rotateEllipse4.Begin();
rotateEllipse4.Stop();
userContextData = service.AuthenticateAsync(user.Text, password.Text);
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.)
mchlsync
Star
14606 points
2,730 Posts
04-18-2008 7:09 AM |
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);}
04-18-2008 7:48 AM |
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);
} }
public void validateUser(object sender, RoutedEventArgs e)
{ service.AuthenticateAsync(user.Text, password.Text);}
04-18-2008 8:31 AM |
Heyyyy, ! its built successfully with out any error, thanks a lot... :)
04-18-2008 8:35 AM |
You are welcome - Please,Mark as Answer
04-18-2008 1:47 PM |
m sorry to ask a stupid doubt, but how to mark it as an answer, i cudnt find that option anywhere!
04-19-2008 12:40 PM |
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.....
04-21-2008 1:33 AM |
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 !! )
04-21-2008 7:23 AM |
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" ?
04-21-2008 10:18 AM |
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.
04-21-2008 11:01 AM |
oops! ok... i got it :)
04-22-2008 1:46 AM |
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.
could anyone tell me the solution for this
04-25-2008 1:33 AM |
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.
04-25-2008 11:06 AM |
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..
deepikaFO
14 points
7 Posts
05-10-2008 6:46 AM |
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
Jim Mangaly
Contributor
2610 points
380 Posts
05-10-2008 12:19 PM |
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
amurawat...
8 points
6 Posts
06-06-2008 8:16 AM |
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.
simbuaar...
Participant
1172 points
405 Posts
12-08-2008 4:07 AM |
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
12-08-2008 4:22 AM |
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
kwells5750
2 points
1 Posts
09-30-2009 7:24 PM |
Thank you Kostja. Your code is very clear and helpful to newbee like me.