创建一个Web服务来接受XML C#

时间:2018-05-10 07:54:16

标签: c# xml web-services

我已经探索过这个网络,但仍然找不到关于如何创建接受XML的Web服务的简单教程/指南。

我创建了以下简单的Web服务,

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]

public class Calculator : System.Web.Services.WebService
{
    public Calculator() {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public long Add(long x, long y) {
        return x + y;
    }

}

现在我需要扩展它,以便Web服务可以接受以下XML,

<?xml version="1.0" encoding="ISO-8859-1"?>
<Root>
    <WorkOrder StatusCode="0" ID="1572058">
        <JobTypeID>2339</JobTypeID>
        <JobTypeDesc>HELPLINE (2339)</JobTypeDesc>
        <AccessRestrictions>Avoid School Run</AccessRestrictions>
        <TenantName>MRS M JOHN & MR A GREY</TenantName>
        <TenantHomeTel>01234567890</TenantHomeTel>
        <TenantMobTel>1213</TenantMobTel>
        <TenantWorkTel/>
        <OrderLines>
            <OrderLine ID="4884180">
                <OrderLineVariedFrom/>
                <Status>0</Status>
                <TradeID>2315</TradeID>     
            </OrderLine>
            <OrderLine ID="4884181">
                <OrderLineVariedFrom/>
                <Status>0</Status>
                <TradeID>2380</TradeID>
            </OrderLine>
        </OrderLines>
        <Vulnerabilities>
            <Vulnerability>3645<Vulnerability/>
        </Vulnerabilities>
    </WorkOrder>
</Root>

非常感谢任何帮助。我是新手,简单的指南/教程将非常有用。非常感谢

0 个答案:

没有答案