需要产生Soap服务,而该服务消耗了产生应用程序/ XML的其余服务。
javax.xml.bind.UnmarshalException:意外元素(uri:“”,本地:“ Response”)。预期的元素是
<{http://www.amfampoc.com/Vehicle}getAllVehicleMakesRequest>,
<{http://www.amfampoc.com/Vehicle}response></faultstring>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://spring.io/guides/gs-producing-web-service"
elementFormDefault="qualified">
<xs:element name="getCountryRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Response">
<xs:complexType>
<xs:sequence>
<xs:element name="Count" type="xs:int" />
<xs:element name="Message" type="xs:string" />
<xs:element name="SearchCriteria" type="xs:string" />
<xs:element name="Results">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="VehicleTypesMakes">
<xs:complexType>
<xs:sequence>
<xs:element name="MakeId" type="xs:int" />
<xs:element name="MakeName" type="xs:string" />
<xs:element name="VehicleTypeId" type="xs:int" />
<xs:element name="VehicleTypeName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" encoding="UTF-8"?>
<Response xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Count>24</Count>
<Message>Response returned successfully</Message>
<SearchCriteria>Make: merc</SearchCriteria>
<Results>
<VehicleTypesMakes>
<MakeId>449</MakeId>
<MakeName>Mercedes-Benz</MakeName>
<VehicleTypeId>2</VehicleTypeId>
<VehicleTypeName>Passenger Car</VehicleTypeName>
</VehicleTypesMakes>
<VehicleTypesMakes>
<MakeId>449</MakeId>
<MakeName>Mercedes-Benz</MakeName>
<VehicleTypeId>3</VehicleTypeId>
<VehicleTypeName>Truck</VehicleTypeName>
</VehicleTypesMakes>
</Results>
</Response>
答案 0 :(得分:0)
XML响应使用默认名称空间作为Response元素,对XSD无效。它应该在命名空间http://spring.io/guides/gs-producing-web-service
中。简而言之,响应中应该有类似<Response xmlns="http://spring.io/guides/gs-producing-web-service" ...>
的内容。