Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Add web reference problem(silverlight 2.0) RSS

34 replies

Last post Oct 01, 2009 12:24 AM by kwells5750

(1)
  • Kostja

    Kostja

    Member

    38 Points

    16 Posts

    Add web reference problem(silverlight 2.0)

    Mar 07, 2008 02:39 PM | LINK

    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 

  • CraigN

    CraigN

    Member

    352 Points

    89 Posts

    Re: Add web reference problem(silverlight 2.0)

    Mar 07, 2008 03:06 PM | LINK

    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
  • Kostja

    Kostja

    Member

    38 Points

    16 Posts

    Re: Add web reference problem(silverlight 2.0)

    Mar 07, 2008 03:32 PM | LINK

    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 [:)]

    Thank you very much!
     

  • CraigN

    CraigN

    Member

    352 Points

    89 Posts

    Re: Add web reference problem(silverlight 2.0)

    Mar 07, 2008 04:06 PM | LINK

     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
  • Kostja

    Kostja

    Member

    38 Points

    16 Posts

    Re: Add web reference problem(silverlight 2.0)

    Mar 07, 2008 04:30 PM | LINK

    Yes it simple[:)]
    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
     

  • CraigN

    CraigN

    Member

    352 Points

    89 Posts

    Re: Add web reference problem(silverlight 2.0)

    Mar 07, 2008 04:44 PM | LINK

    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
  • Kostja

    Kostja

    Member

    38 Points

    16 Posts

    Re: Add web reference problem(silverlight 2.0)

    Mar 07, 2008 05:10 PM | LINK

     Thank you - it works

  • bscc

    bscc

    Member

    6 Points

    5 Posts

    Re: Re: Add web reference problem(silverlight 2.0)

    Mar 24, 2008 12:47 PM | LINK

    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

     

  • Kostja

    Kostja

    Member

    38 Points

    16 Posts

    Re: Re: Add web reference problem(silverlight 2.0)

    Mar 24, 2008 02:54 PM | LINK

    Please show your code

  • wireplay

    wireplay

    Member

    44 Points

    20 Posts

    Re: Re: Re: Add web reference problem(silverlight 2.0)

    Apr 02, 2008 02:28 AM | LINK

    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.