JAXB : 요소는 속성이 아닌 유형의 이름을 따서 명명되었습니다.

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

  •  22-07-2019
  •  | 
  •  

문제

웹 서비스 WSDL에는 다음 스키마가 포함됩니다.

<xs:complexType name="DocumentSearchInfo">
    <xs:sequence>
     ...
       <xs:element minOccurs="0" name="Industries" nillable="true" type="tns:ListCondition">
        <xs:annotation>
          <xs:appinfo>
            <DefaultValue EmitDefaultValue="false" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" />
          </xs:appinfo>
        </xs:annotation>
       </xs:element>
   ...
    </xs:sequence>
  </xs:complexType>

이 코드는 NetBeans 6.7에서 웹 참조를 추가하여 생성되었습니다.

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "DocumentSearchInfo", propOrder = {
    "analysts",
    "companyIDCondition",
    "contributorCondition",
    "countries",
    "dateRange",
    "documentIDCondition",
    "documentPageCondition",
    "industries",
    "keywordCondition",
    "languages",
    "profileID",
    "purchasedOnly",
    "regions",
    "researchCategories",
    "researchProduct"
})

    public class DocumentSearchInfo {
    ...
      @XmlElementRef(name = "Industries", namespace = "http://somenshere", type = JAXBElement.class)
        protected JAXBElement<ListCondition> industries;
    ...
    }

차례로 일련의로 들어갑니다

<ns2:SearchInfo>
 ...
   <ns2:ListCondition>
     <ns2:Values>
       <ns3:string>1385</ns3:string>
       <ns3:string>1386</ns3:string>
     </ns2:Values>
   </ns2:ListCondition>
 ...
</ns2:SearchInfo>

이 XML에서 'ListCondition'이 아닌 'Industries'를 볼 것으로 기대합니다.

.NET 로이 서비스를 소비하는 데 아무런 문제가 없었습니다.

누구든지 도울 수 있습니까?

도움이 되었습니까?

해결책

해결되었습니다. 나는 ObjectFactory의 wayedocumentsearchinfoindustries 방법을 불렀어야했다. .NET에서 익숙한 것과는 매우 다릅니다)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top