Mono WSDL 유틸리티는 SOAP API에 대한 eBay의 WSDL 파일을 처리하지 못합니다.

StackOverflow https://stackoverflow.com/questions/1451176

문제

eBay의 WSDL 파일을 처리하려고하면서 Mono의 WSDL 유틸리티 에서이 오류가 발생합니다.

( 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]

솔루션을 위해 Google을 검색하면 시작하는 요소가 변경되는 제안이 있습니다. <xs:any ... 에게 <xs:any namespace="##other" ... - 이것은 확실히 모노의 WSDL 유틸리티가 파일을 처리하여 .cs 파일을 만들 수있게합니다. 그러나 Webservice Helper 클래스를 인스턴스화하려고 할 때 C# 프로그램에서 런타임 예외를 얻습니다. 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 ---

Mono의 WSDL 도구는 여기에 있어야합니까, 아니면 eBay의 WSDL/스키마입니까? -WSDL이 스키마와 일치하지 않는다고 말한 여러 포럼 게시물이므로 Mono는 올바른 일을하고 있지만 C#에서 Webservice Helper 클래스를 인스턴스화 할 수 있도록 어떻게 수정해야합니까?

내 도구의 버전 :

$ WSDL 웹 서비스 설명 언어 유틸리티 모노 프레임 워크 v2.0.50727.1433

$ gmcs -version mono 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;
        }
    }
}

내 'fix'가 여기

도움이 되었습니까?

해결책

이것이 당신의 문제를 해결하는지 모르겠지만 xs:any 와일드 카드 귀하의 질문에서 두 가지가 없습니다 '#':

<xs:any namespace="##other" ...
                   ↑

생성 된 C# 코드에는 다음과 같은 많은 정의가 포함되어 있습니다.

[System.Xml.Serialization.XmlAnyElement(Namespace="")]
public System.Xml.XmlElement[] Any {
    get {
        return this.anyFieldXXX;
    }
    set {
        this.anyFieldXXX = value;
    }
}

에서 MSDN:

적용하십시오 XmlAnyElementAttribute 배열을 반환하는 필드에 XmlElement 또는 XmlNode 사물. 이러한 필드는 물체가 직렬화되었는지 또는 사제화되는지에 따라 두 가지 방식으로 사용될 수 있습니다. 직렬화되면 객체는 직렬화되는 객체에 해당 부재 (또는 멤버)가 없지만 XML 요소 또는 노드로 생성됩니다. 당신이 지정하는 경우 a Name 속성 값 속성을 적용 할 때 모두 XmlElement 또는 XmlNode 배열에 삽입 된 객체는 동일한 요소 이름과 기본 네임 스페이스를 가져야하거나 예외가 발생해야합니다. 당신이 설정하면 Namespace 속성 값, 당신은 설정해야합니다 Name 재산도, 그리고 XmlElement 또는 XmlNode 객체는 또한 동일한 이름과 네임 스페이스 값을 가져야합니다. 그렇지 않다면 Name 값은 지정됩니다 XmlElement 또는 XmlNode 객체는 요소 이름을 가질 수 있습니다.

그래서 나는 해결책이 단순히 Namespace 속성 값 :

[System.Xml.Serialization.XmlAnyElement]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top