我從Mono的WSDL工具在嘗試處理eBay的WSDL文件收到此錯誤 -單WSDL工具無法處理eBay的WSDL文件的SOAP API
(http://developer.ebay.com/webservices/latest/eBaySvc.wsdl)
$ wsdl eBaySvc.wsdl
Web Services Description Language Utility
Mono Framework v2.0.50727.1433
Error: XmlSchema error: Ambiguous element label which is contained by -any- particle was detected: urn:ebay:apis:eBLBaseComponents:PreferenceLevel Related schema item SourceUri: file:///home/manger/projects/ebay/eBaySvc.orig.wsdl, Line 10296, Position 7.
Stack:
at System.Xml.Schema.ValidationHandler.RaiseValidationEvent (System.Xml.Schema.ValidationEventHandler handle, System.Exception innerException, System.String message, System.Xml.Schema.XmlSchemaObject xsobj, System.Object sender, System.String sourceUri, XmlSeverityType severity) [0x00000]
at System.Xml.Schema.XmlSchemaObject.error (System.Xml.Schema.ValidationEventHandler handle, System.String message, System.Exception innerException, System.Xml.Schema.XmlSchemaObject xsobj, System.Object sender) [0x00000]
at System.Xml.Schema.XmlSchemaObject.error (System.Xml.Schema.ValidationEventHandler handle, System.String message) [0x00000]
搜索谷歌對於解決方案揭示了一個改變元素的建議,以<xs:any ...
到<xs:any namespace="##other" ...
開頭 - 這當然會使Mono的wsdl實用程序能夠處理該文件,從而製作一個.cs文件。但後來我從我的C#程序得到一個運行時異常,當我嘗試實例化Web服務輔助類(eBayAPIInterfaceService service = new eBayAPIInterfaceService();
):
Unhandled Exception: System.InvalidOperationException: There was an error reflecting type 'AddDisputeRequestType'. ---> System.InvalidOperationException: There was an error reflecting field 'DetailLevel'. ---> System.InvalidOperationException: There was an error reflecting type 'DetailLevelCodeType'. ---> System.InvalidOperationException: There was an error reflecting type 'System.Object'. ---> System.InvalidOperationException: There was an error reflecting type 'AbstractResponseType'. ---> System.InvalidOperationException: There was an error reflecting field 'Errors'. ---> System.InvalidOperationException: There was an error reflecting type 'ErrorType'. ---> System.InvalidOperationException: There was an error reflecting field 'ErrorParameters'. ---> System.InvalidOperationException: There was an error reflecting type 'ErrorParameterType'. ---> System.InvalidOperationException: There was an error reflecting field 'Any'. ---> System.InvalidOperationException: The element Any has been attributed with an XmlAnyElementAttribute and a namespace '', but no name. When a namespace is supplied, a name is also required. Supply a name or remove the namespace.
at System.Xml.Serialization.XmlReflectionImporter.ImportAnyElementInfo (System.String defaultNamespace, System.Xml.Serialization.XmlReflectionMember rmember, System.Xml.Serialization.XmlTypeMapMemberElement member, System.Xml.Serialization.XmlAttributes atts) [0x00000]
at System.Xml.Serialization.XmlReflectionImporter.CreateMapMember (System.Type declaringType, System.Xml.Serialization.XmlReflectionMember rmember, System.String defaultNamespace) [0x00000]
at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00000]
--- End of inner exception stack trace ---
在故障單的WSDL工具在這裏,或eBay的WSDL /架構? - 我見過的幾篇論壇帖子都說WSDL與模式不匹配,所以Mono做的是正確的事情,但我該如何解決它,以便我可以實例化C#中的webservice輔助類?我的工具
版本:
$ WSDL Web服務描述語言工具 單框架v2.0.50727.1433
$的GMC --version 單聲道C#編譯器版本2.4.2.3
生成的ErrorParameterType代碼:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.1433")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:ebay:apis:eBLBaseComponents")]
public partial class ErrorParameterType {
private System.Xml.XmlElement[] anyField165;
... more class members follow ...
/// <remarks/>
[System.Xml.Serialization.XmlAnyElement(Namespace="")]
public System.Xml.XmlElement[] Any {
get {
return this.anyField165;
}
set {
this.anyField165 = value;
}
}
}
eB之後我的「修復」該WSDL產生ayAPIInterfaceService.cs文件here
如何爲'ErrorParameterType.Any'生成的代碼是什麼樣子? – dtb 2009-09-20 14:56:27
@dtb:我已經將ErrorParameterType的定義添加到問題文本中,我無法在源代碼中找到「ErrorParameterType.Any」。我已經添加了一個鏈接到正在生成的完整.cs文件。該鏈接的Makefile和我的test.cs在同一個目錄中。 – matja 2009-09-20 15:29:24
'Namespace =「」'似乎是罪魁禍首;我在MSDN上找到了一個報價(請參閱我的答案)。 – dtb 2009-09-20 15:48:10