SOA Demo, soademo

Source: Internet
Author: User

SOA Demo, soademo

UseSOATo add two numbers without verification.

PDF: http://files.cnblogs.com/chenyongblog/SOA_Demo.pdf

Source code download: http://files.cnblogs.com/chenyongblog/WCFTest.7z

1. First define an interface ICalculate

(1) Introduce System. ServiceModel assembly

(2) Public interface: Use ServiceContract to define the service contract (Mark interface) and OpeattionContract to mark the Method

using System.ServiceModel;namespace CalculateImplement{    [ServiceContract]    public interface ICalculate    {        [OperationContract]        double Add(double x, double y);    }}

2. Interface implementation

 

namespace CalculateImplement{    public class Calculate : ICalculate    {        public double Add(double x, double y)        {            return x + y;        }    }}

3. Host Management Service

<?xml version="1.0" encoding="utf-8" ?><configuration>    <startup>         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />    </startup>      <!--WCF Setting-->  <system.serviceModel>    <services>      <service name="CalculateImplement.Calculate" behaviorConfiguration="serviceBehavior">        
using System;using System.ServiceModel;using CalculateImplement;namespace HostService{    class Program    {        static void Main(string[] args)        {            ServiceHost host = new ServiceHost(typeof(Calculate));            try            {                host.Open();                Console.WriteLine("Service is open......");                Console.ReadLine();                host.Close();            }            catch (Exception et)            {                                throw et;            }        }    }}

4. enable Host, add Service on the Client, and modify the namespace

 

Client code:

 

using System;namespace Client{    class Program    {        static void Main(string[] args)        {            CalculateService.CalculateClient calculate = new CalculateService.CalculateClient();            Console.WriteLine("SOA Demo");            Console.Write("Please enter the first number:");            double num1 = Convert.ToDouble(Console.ReadLine());            Console.Write("Please enter the second number:");            double num2 = Convert.ToDouble(Console.ReadLine());            double result = calculate.Add(num1, num2);            Console.WriteLine("Add result:" + result);            Console.ReadLine();        }    }}

Program running:

 

 

 


Now I am studying SOA, ESB, JAVA source code

Components such as service oriented architecture are generally the core technology of the company, and the architecture method is also very complicated. You should go to the open-source community in a foreign country and check the demo.

Help me with soaoffice Problems

If you use fileupload to upload the file to the server, it will be difficult to use the program to obtain the number of pages of the file. Unless you use the server-side COM automation, the server must first install the office, then, use a program to create an automatic word object, and then try to read the document's page number. The idea is like this, but Microsoft does not recommend server-side com automation, or do not. Official Microsoft explanation: support.microsoft.com/..257757

If you use soaoffice (preferably version 7.1 or later), the solution is as follows:
1. Integrated with SOAOffice, you can click "open" in the "file" menu of the client control and select the local file to be uploaded.
2. When the user clicks save, let the control execute js to set a hidden Input value equal to the following value
SOAOfficeCtrl. Document. Application. Selection. Information (4 );
3. Obtain the Input value on the server and store it in the records of the corresponding files in the database.

If C # is used, you can debug soacsharpdemo in the "sample code" directory,
1. modify the code in the html tag on the simple. aspx page to the following code:
<HTML>
<HEAD>
</HEAD>
<Body>

<Form name = "formData" method = "post" id = "formData">
<! ********************* *** -->
<Input type = "text" id = "PageNum" name = "PageNum"/>
<SCRIPT language = "javascript" event = "OnInit ()" for = "SOAOfficeCtrl">
// The control is triggered before the document is opened. It is used to initialize the interface style.
</SCRIPT>
<SCRIPT language = "javascript" event = "onreceiventopened (str, obj)" for = "SOAOfficeCtrl">
// The control is triggered immediately after the document is opened. You can add a custom menu, customize the toolbar, disable printing, prohibit saving, and so on.
BDocOpen = true;
SOAOfficeCtrl. EnableFileCommand (3) = false;
SOAOfficeCtrl. AppendToolButton (1, "save", 1 );
</SCRIPT>
<SCRIPT language = "javascript" event = "OnDocumentClosed ()" for = "SOAOfficeCtrl & ...... the remaining full text>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.