Java WSO2 ESB-webservice响应:null

Java WSO2 ESB-webservice响应:null,java,web-services,null,wso2esb,Java,Web Services,Null,Wso2esb,我在WSO2 ESB中创建了一个代理服务,它接收来自webservice的请求,该服务没有参数和基于xml文件的响应。这是我的WSDL(名为itemcat.WSDL): 使用WSO2 ESB控制台上的“尝试此服务”,我得到了确定的结果: <ItemCategories> <ItemCategory value="Intermediate" description="Intermediate"/> <ItemCategory value="Componen

我在WSO2 ESB中创建了一个代理服务,它接收来自webservice的请求,该服务没有参数和基于xml文件的响应。这是我的WSDL(名为itemcat.WSDL):

使用WSO2 ESB控制台上的“尝试此服务”,我得到了确定的结果:

<ItemCategories>
   <ItemCategory value="Intermediate" description="Intermediate"/>
   <ItemCategory value="Component" description="General"/>
   <ItemCategory value="Finished" description="Finished"/>
   <ItemCategory value="Raw" description="Raw"/>
</ItemCategories>
第20行是第一行

   List<ItemCategory> list = itens.getItemCategory();
List List=itens.getItemCategory();
当我调试(使用eclipse)中介代码时,我看到里面的一切都正常。它返回正常


有人能帮我找到为什么Web服务客户端从服务器接收空值吗?

太复杂了(显然
itens
是空的)。。。尝试降低给定测试用例的复杂性。使用http代理调试流时发现soap消息(响应)是来自请求的回显。这意味着问题出在服务器上。还在工作。。。
<sequence xmlns="http://ws.apache.org/ns/synapse" name="ItemCategoriesSequence">
    <header action="remove" name="To"/>
    <property action="set" name="RESPONSE" scope="default" type="STRING" value="true"/>
    <property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
    <property action="set" name="FileLocation" scope="default"
        type="STRING" value="/home/user/Desktop/itemcat.txt"/>
    <class name="com.myplace.esb.mediator.ItemCategoriesTextFile"/>
    <send/>
</sequence>
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;

import javax.validation.Validation;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.LineIterator;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;

public class ItemCategoriesTextFile extends AbstractMediator {

    /**
     * Property name for file location.
     */
    private static final String FILE_LOCATION = "FileLocation";

    /**
     * File content parameters.
     */
    private static final int EXPECTED_COLUMNS = 2;
    private static final String COLUMN_SEPARATOR_REGEXP = "\\t";

    @Override
    public boolean mediate(MessageContext context) {
        final String property = (String) context.getProperty(FILE_LOCATION);
        if (property == null) {
            log.warn("Property [" + FILE_LOCATION + "] null");
            return false;
        }
        final ItemCategories categories = new ItemCategories();
        LineIterator it;
        try {
            it = FileUtils.lineIterator(new File(property));
        } catch (IOException e) {
            log.warn("Error processing file [" + property + "]", e);
            return false;
        }
        // iterate over each line
        try {
            while (it.hasNext()) {
                final String line = it.nextLine();
                final boolean parsed = parseLine(categories, line);
                if (!parsed) {
                    // something went wrong
                    return false;
                }
            }
        } finally {
            LineIterator.closeQuietly(it);
        }
        try {
            response(context, categories, ItemCategories.class);
        } catch (Exception e) {
            log.warn("Error processing xml", e);
            return false;
        }
        return true;
    }

    private boolean parseLine(final ItemCategories itemcats, final String line) {
        final String[] split = line.split(COLUMN_SEPARATOR_REGEXP,
                EXPECTED_COLUMNS);
        if (split.length != EXPECTED_COLUMNS) {
            log.warn("Expected [" + EXPECTED_COLUMNS
                    + "] or less columns for each line inside the file");
            return false;
        }
        final ItemCategory itemcat = new ItemCategory(split[0], split[1]);
        if (!Validation.buildDefaultValidatorFactory().getValidator()
                .validate(itemcat).isEmpty()) {
            log.warn("Constraints not satisfied for line [" + line + "]");
            return false;
        }
        itemcats.addItemCategory(itemcat);
        return true;
    }

    /**
     * 
     * @param context
     *            response message context.
     * @param data
     *            data that will go to xml.
     * @param clazz
     *            class on top of xml.
     * @throws Exception
     *             any problem parsing xml.
     */
    private void response(MessageContext context, final Object data,
            final Class<?> clazz) throws Exception {
        final JAXBContext jc = JAXBContext.newInstance(clazz);
        final Marshaller marshaller = jc.createMarshaller();
        final StringWriter writer = new StringWriter();
        // removes the <xml> tag
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
        marshaller.marshal(data, writer);
        final OMElement root = OMXMLBuilderFactory.createOMBuilder(
                new ByteArrayInputStream(writer.toString().getBytes()))
                .getDocumentElement();
        context.getEnvelope().getBody().addChild(root);
    }
Raw Raw
Component   General
Intermediate    Intermediate
Finished    Finished
<ItemCategories>
   <ItemCategory value="Intermediate" description="Intermediate"/>
   <ItemCategory value="Component" description="General"/>
   <ItemCategory value="Finished" description="Finished"/>
   <ItemCategory value="Raw" description="Raw"/>
</ItemCategories>
public class Main {

    public static void main(String[] args) throws MalformedURLException {
        URL url = new URL("http://localhost:8280/services/ItemCategoriesService?wsdl");
        ItemCategoriesService service = new ItemCategoriesService(url);
        ItemCategoriesPortType port = service.getItemCategoriesEndPoint();
        ItemCategoriesResponse resp = port.getItemCategories(new ItemCategoriesRequest());
        ItemCategories itens = resp.getItemCategories();
        List<ItemCategory> list = itens.getItemCategory();
        for(ItemCategory t : list){
            System.out.println(t);
        }
    }

}
Exception in thread "main" java.lang.NullPointerException
    at Main.main(Main.java:20)
   List<ItemCategory> list = itens.getItemCategory();