我是 Spring WS 和 JiBX 的新手。我没有使用注释。在 Spring WS 中使用 Jibx 时出现以下错误。
JiBX unmarshalling exception: No unmarshaller for element "{http://www.visu.com/pos/soapws/}orderRequest" (line 1, col 103); nested exception is org.jibx.runtime.JiBXException: No unmarshaller for element "{http://www.visu.com/pos/soapws/}orderRequest"
这是我的端点和弹簧配置
public class OrderEndPoint extends AbstractMarshallingPayloadEndpoint{
private Marshaller marshaller;
private Unmarshaller unmarshaller;
private OrderService orderService;
public OrderEndPoint(final OrderService orderService, final Marshaller marshaller, final Unmarshaller unmarshaller) {
super(marshaller);
super.setUnmarshaller(unmarshaller);
//this.marshaller = marshaller;
//this.unmarshaller = unmarshaller;
this.orderService = orderService;
System.out.println("This is Order End point constructor");
}
@Override
protected Object invokeInternal(final Object newOrder) throws Exception {
System.out.println("This is test for Invoke Internal");
final OrderRequest orderReq = (OrderRequest)newOrder;
final Order order = orderReq.getOrder();
this.orderService.placeOrder(order);
return "Order with the order number "+order.getOrderNumber()+" saved successfully";
}
}
<!-- Jibx marshellers -->
<bean id="unmarshaller" class="org.springframework.oxm.jibx.JibxMarshaller">
<property name="targetClass" value="com.visu.pos.soapws.model.OrderRequest"/>
<property name="bindingName" value="binding"/>
</bean>
<bean id="marshaller" class="org.springframework.oxm.jibx.JibxMarshaller">
<property name="targetClass" value="com.visu.pos.soapws.model.OrderResponse"/>
<property name="bindingName" value="binding"/>
</bean>
下面是用于绑定的 Order.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.visu.com/pos/soapws/" elementFormDefault="qualified" targetNamespace="http://www.visu.com/pos/soapws/">
<xs:element type="tns:orderRequest" name="orderRequest"/>
<xs:complexType name="orderRequest">
<xs:sequence>
<xs:element type="tns:order" name="order" minOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:element type="tns:order" name="order"/>
<xs:complexType name="order">
<xs:sequence>
<xs:element name="customer" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="firstName" minOccurs="0"/>
<xs:element type="xs:string" name="lastName" minOccurs="0"/>
<xs:element type="xs:string" name="middleName" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute type="xs:long" use="required" name="customerNumber"/>
</xs:complexType>
</xs:element>
<xs:element type="tns:address" name="billTo" minOccurs="0"/>
<xs:element name="shipping" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="STANDARD_MAIL"/>
<xs:enumeration value="PRIORITY_MAIL"/>
<xs:enumeration value="INTERNATIONAL_MAIL"/>
<xs:enumeration value="DOMESTIC_EXPRESS"/>
<xs:enumeration value="INTERNATIONAL_EXPRESS"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element type="tns:address" name="shipTo" minOccurs="0"/>
<xs:element name="item" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="id" minOccurs="0"/>
<xs:element type="xs:string" name="description" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:int" use="required" name="quantity"/>
<xs:attribute type="xs:float" use="required" name="price"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:long" use="required" name="orderNumber"/>
<xs:attribute type="xs:date" name="orderDate"/>
<xs:attribute type="xs:date" name="shipDate"/>
<xs:attribute type="xs:float" name="total"/>
</xs:complexType>
<xs:complexType name="address">
<xs:sequence>
<xs:element type="xs:string" name="street1" minOccurs="0"/>
<xs:element type="xs:string" name="street2" minOccurs="0"/>
<xs:element type="xs:string" name="city" minOccurs="0"/>
<xs:element type="xs:string" name="state" minOccurs="0"/>
<xs:element type="xs:string" name="postCode" minOccurs="0"/>
<xs:element type="xs:string" name="country" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="orderResponse">
<xs:sequence>
<xs:element type="xs:string" name="orderResponse" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element type="tns:orderResponse" name="orderResponse"/>
</xs:schema>
网上验证Jibx实现不需要单独Marshaller和Unmarshaller。虽然我声明了编组器,但它抛出了这个错误。我尝试了所有可用的选项,但没有用。请在这方面提供帮助。提前致谢!!