当前位置: 首页 > 知识库问答 >
问题:

unmarshalException:意外元素(URI:“”,local:“arg0”)。需要的元素为

柴丰
2023-03-14
            JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
            factory.setServiceClass(ICustomer.class);
            factory.setAddress("http://localhost:8080/backend/services/CustomerInfo");
            ICustomer client = (ICustomer) factory.create();

            // Below is the service call. where 'object' is my CustomerInfo object/data
            client.saveCustomer(object);
@WebService(endpointInterface = "com.dev.backend.services.interfaces.ICustomer", serviceName="CustomerInfo")
public class ICustomerImpl implements ICustomer {

public boolean saveCustomer(Object object) {
    JAXBContext payloadContext;
    try {
        payloadContext = JAXBContext.newInstance(CustomerInfo.class);
        CustomerInfo o = (CustomerInfo)payloadContext.createUnmarshaller().unmarshal((Node)object); // Line 'error'
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

谢谢

共有1个答案

阎德义
2023-03-14

您有这样的XML节点吗?

<ws:customerInfo> ... </ws:customerInfo>

如果有,请尝试删除“ws”

更新:如果您有类似于此的方法:

public ReturnType Method1(
            @WebParam(name="RequestType1") RequestType1 request)
public ReturnType Method1(
                @WebParam(name="requestType1") RequestType1 request)
 类似资料: