Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy Silverlight and Web Service

2025-03-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

The editor will share with you how to deploy Silverlight and Web Service. I hope you will get something after reading this article. Let's discuss it together.

Having been testing Silverlight through Visual Studio, I thought it would be easy to deploy to the server.

Unexpectedly, I encountered a lot of trouble and spent a whole day searching for a solution.

First, it is deployed to the local IIS under the xp system, and so is the server win2003.

As shown in the figure, right-click virtual directory-> Properties-> HTTP header-> MIME type. Add

Extension: .xap

MIME type: application/x-silverlight-app

Extension: .xaml

MIME type: application/xaml+xml

This will allow the Silverlight to be displayed normally.

If you call Web Service

And your Web Service is under the website that hosts Silverlight. As shown in the picture

This does not involve the hassle of cross-domain operations.

But you can't directly quote local services like localhost.

Otherwise, it will not be possible to deploy on the server.

My method is to deploy this service on the local IIS first.

Then add a service reference.

For example, the address is http://127.0.0.1:8088/sl/LinqXmlService.asmx

There is no cross-domain operation at this time. The test is successful first.

Then open the service reference directory, as shown in the figure

Open all the files here with vs, then replace them with Ctrl+H, and select all open documents.

Replace http://127.0.0.1:8088/sl/LinqXmlService.asmx with

Http://www.weiqi9d.com/LinqXmlService.asmx

That's your server address.

I don't know how I thought of it. I tried it. It's OK.

Another problem is that .xap is still inaccessible on the server. I don't know why.

I had to change the .xap to .htm and change it here, too.

As shown in the picture

In this way, even if your sl is developed in vs2010 and the server does not have .net 4.0 installed, it will display normally.

Record the method that Silverlight calls Web Service.

Using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services Summary description of namespace SilverlightApplication2.Web {/ WebService1 / [WebService (Namespace = "http://tempuri.org/")] [WebServiceBinding (ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem (false)] / / to allow this Web service to be called from a script using ASP.NET AJAX, uncomment the following line. / / [System.Web.Script.Services.ScriptService] public class WebService1: System.Web.Services.WebService {[WebMethod] public string HelloWorld () {return "HelloWorld";} call using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents Using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightApplication2 {public partial class MainPage: UserControl {public MainPage () {InitializeComponent (); this.Loaded + = new RoutedEventHandler (Page_Loaded) } / / create Web Service object ServiceReference1.LinqXmlServiceSoapClient ws = new ServiceReference1.LinqXmlServiceSoapClient (); void Page_Loaded (object sender, RoutedEventArgs e) {AddEvent (); Bind () } / / Registration event, somewhat similar to Ajax's callback private void AddEvent () {ws.HelloWorldCompleted + = new EventHandler (ws_HelloWorldCompleted);} / / callback function void ws_HelloWorldCompleted (object sender, ServiceReference1.HelloWorldCompletedEventArgs e) {button1.Content + = e.Result + "hi" / / MessageBox.Show (e.Result);} private void Bind () {ws.HelloWorldAsync ();} after reading this article, I believe you have some understanding of "how to deploy Silverlight and Web Service". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report