WebService how to generate objects based on the XML provided by the other party

Source: Internet
Author: User

Recently write the interface to a requirement that they push the data over to us to provide the service interface.

The other side uses. NET WebService, which has already defined all the object formats, possibly to accommodate the versatility of each platform, so that only XML-formatted parameters are available in the document.

But if we call our interfaces, they will still be accessed through the objects they define, and XML is just the intermediate transfer data format.

Then we are going to convert the XML they provide into objects (. cs files).

The first step:

In the Start menu, locate Visual Studio Tools under Visual Studio to open the VS2013 Developer command prompt, which differs depending on the VS version name.

Step Two:

Run at command line: Xsd.exe XML file address space/outputdir: address of XSD

Why is it that generating an XSD file instead of directly generating a. cs file is not really clear to me, the approximate conversion process is:

. Xml=>.xsd=>.cs

Step Three:

Continue execution: Xsd.exe xsd file address space/classes/outputdir: classfile Address

After the above steps, the XML object's class file is generated.

If you have written WebService's small partners should be able to find that the generated object class format, and WebService reference to the service object code format is the same.

So I think Visual Studio should also use the Xsd.exe tool when referencing the service.

It is also possible to generate an object class from this method, even if it is not a WebService object-generated XML.

Xsd.exe other specific parameters:
XSD file.xdr [/outputdir:directory][/parameters:file.xml]
XSD file.xml [/outputdir:directory] [/parameters:file.xml]
xsd file.xsd {/classes |/dataset} [/element:element]
[/enablelinqdataset] [/language:language]
[/namespace:namespace] [/outputdir:directory] [Uri:uri]
[/parameters:file.xml]
xsd {file.dll | file.exe} [/outputdir:directory] [/type:typename [...] [/parameters:file.xml]

Part of the content is excerpted from: http://www.cnblogs.com/weiwin/p/xmltoclass.html

WebService how to generate objects based on the XML provided by the other party

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.