产生具有确切的命名空间DataContracts在XSD [英] Generating DataContracts with exact namespace as in XSD

查看:197
本文介绍了产生具有确切的命名空间DataContracts在XSD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有我们与后端Oracle平台项目集成。而这种集成是通过不同的Web服务。我对所有这些集成所有WSDL和XSD。而我需要生成这些WSDL文件&放DataContracts; XSD中。结果
现在的问题是,大多是所有这些整合股一些常见的数据类型。我想重用他们结果
例如,

We have to integrate our project with back end Oracle Platform. And this integration is via various WebServices. I have all WSDLs and XSDs for all these integrations. And I need to generate DataContracts from these WSDLs & XSDs.
Now the problem is, mostly all of these integration shares some common data types. and I want to reuse them.
e.g,


Integration1: oracle/common/commonDataTypes.xsd
              oracle/integration1/someXSD.xsd
              oracle/ebo/baseTypes.xsd
Integration2: oracle/common/commonDataTypes.xsd
              oracle/integration2/someXSD.xsd
              oracle/ebo/baseTypes.xsd
Integration3: oracle/commonDataTypes.xsd
              oracle/integration2/someXSD.xsd
              oracle/ebo/baseTypes.xsd

在这种情况下,我想重用integration1与放大器之间的oracle.common.CommonDataTypes; 2.结果
到目前为止,我已经试过WSCF.blue&安培; WSCF。但是,这些工具生成的所有代码在一个文件夹(和单一命名空间),而不是下面的命名空间。结果
我想下生成,如Oracle,oracle.commonData,oracle.integration1,oracle.ebo等类的命名空间
这样是生成Datacontracts任何方式如下确切的命名空间的符号作为的XSD有哪些?

in this case, I want to reuse the oracle.common.CommonDataTypes between integration1 & 2.
so far I have tried WSCF.blue & WSCF. But these tools generating all the code in a single folder(and single namespace) and not following namespaces.
I want to generate classes under namespaces like oracle, oracle.commonData, oracle.integration1, oracle.ebo etc. so is that any way that generated Datacontracts follows exact namespace notation as the XSDs have?

推荐答案

有没有工具,它会为你恐怕这样做。或者没有,我知道的。到acheive你想要的东西的最佳方式是:

There is no tool which will do this for you I'm afraid. Or none that I know of. The best way to acheive what you want is:


  1. 使用/ dconly提取
    积分1中的数据合同标志$上SvcUtil工具b $湾您需要包括所有
    在调用
    SvcUtil工具的模式名称。这将产生与所有类型的类
    档。

  1. Extract the data contracts for integration 1 using the /dconly flag on svcutil. You need to include all the schema names in the call to svcutil. This will generate a class file with all the types.

将进入文件并手动
劈周围,直到你的类是
都在正确的命名空间。编译
到这一组件。

Go into the file and manually hack around until your classes are all in the right namespaces. Compile this into an assembly.

然后回到积分1
服务,并使用生成的代理代码
/ r标志的SvcUtil工具到
参考您的包含

重用您共同装配类型。这将创建一个包含您的代理应该
引用您的常见类型的类文件

Then go back to the integration 1 service and generate your proxy code using the /r flag in svcutil to reference your assembly containing your common types which you want to reuse. This will create a class file containing your proxy which should reference your common types.

您就可以做
集成2和3是一样的。

You can then do the same for integration 2 and 3.

然而,该方法是基于SvcUtil工具使用的DataContractSerializer做的工作,因为/ R标志不提供给XmlSerializer的。如果暴露在Oracle服务的模式坚持相当严格的规则,DCS,这只会工作(可以在这里找到:的 http://msdn.microsoft.com/en-us/library/ms733112.aspx )。如果这些规则不遵守则SvcUtil工具将回落到使用XmlSerializer的不支持的类型重用。

However, this approach is based on svcutil using the DataContractSerializer to do the work, as the /r flag is not available to XmlSerializer. And this will only work if the schemas exposed on the oracle services adhere to the rather strict DCS rules (can be found here: http://msdn.microsoft.com/en-us/library/ms733112.aspx). If these rules are not adhered to then svcutil will fall back to using XmlSerializer which does not support reuse of types.

希望这有助于。

这篇关于产生具有确切的命名空间DataContracts在XSD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆