Silverlight+JavaをRESTとLinq to XMLで。


やったった。同一サイト上なければ、やっぱりcrossdomain.xmlが必要になる。


SOAPベースよりも、RESTベースのほうが楽だと思うなあ。
JavaサイドもPOXをHttpServletResponseに書き込めばいいだけだし。



XAMLのコードビハインドはこんな感じ。

namespace Sample1
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            //Java側
            string url = "http://localhost:8080/samples/silverlight/greet";
            WebClient client = new WebClient();
            client.DownloadStringCompleted += (_s, _e) =>
            {
                if (_e.Error == null)
                {
                    string result = _e.Result;
                    XDocument doc = XDocument.Parse(result);
                    XElement elem = doc.Element("greet");
                    greet.Text = elem.Value;
                }
                else
                {
                    debug.Text = _e.Error.Message;
                }
            };
            client.DownloadStringAsync(new Uri(url));
            
        }

    }
}

いずれSOAPベースも試すと思う、たぶん。