JAX-WS。 SOAP响应主体<return>标签到自定义标签</return>

时间:2014-06-19 08:29:01

标签: java eclipse soap jax-ws glassfish-4

当我尝试使用JAX-WS服务部署时,我在Glassfish 4中收到部署时错误 一个@WebResult注释方法。以下是文物。

@WebService(name = "TestMartCatalog", targetNamespace = "http://www.testmart.com")
public interface ProductCatalogInterface {

    @WebMethod(action = "fetch_categories", operationName = "fetchCategories")
    public abstract List<String> getProductCatagories();

    @WebMethod
    public abstract List<String> getProducts(String category);

    @WebMethod
    public abstract boolean addProduct(String category, String product);

    @WebMethod
    @WebResult(name="Product")
    public abstract List<Product> getProductsv2(String category);

}

@WebService(endpointInterface="come.lets.learn.jaxws.ProductCatalogInterface",
        portName="TestMartCatalogPort", serviceName = "TestMartCatalogService")
public class ProductCatalog implements ProductCatalogInterface {

    ProductServiceImpl prodImpl = new ProductServiceImpl();

    /* (non-Javadoc)
     * @see come.lets.learn.jaxws.ProductCatalogInterface#getProductCatagories()
     */
    @Override
    public List<String> getProductCatagories() {
        return prodImpl.getProductCatagories();
    }

    /* (non-Javadoc)
     * @see come.lets.learn.jaxws.ProductCatalogInterface#getProducts(java.lang.String)
     */
    @Override
    public List<String> getProducts(String category) {
        return prodImpl.getProducts(category);
    }

    /* (non-Javadoc)
     * @see come.lets.learn.jaxws.ProductCatalogInterface#addProduct(java.lang.String, java.lang.String)
     */
    @Override
    public boolean addProduct(String category, String product) {
        return prodImpl.addProduct(category, product);
    }

    /* (non-Javadoc)
     * @see come.lets.learn.jaxws.ProductCatalogInterface#getProductsv2(java.lang.String)
     */
    @Override
    public List<Product> getProductsv2(String category) {
        return prodImpl.getProductsv2(category);
    }

}

@XmlRootElement(name="Product")
@XmlType(propOrder={"price", "sku", "name"})
public class Product {

    private String name;
    private String sku;
    private double price;

    public Product() {

    }

    public Product(String name, String sku, double price) {
        this.name = name;
        this.sku = sku;
        this.price = price;
    }

    /**
     * @return the name
     */
    @XmlElement(name="ProductName")
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the sku
     */
    public String getSku() {
        return sku;
    }

    /**
     * @param sku the sku to set
     */
    public void setSku(String sku) {
        this.sku = sku;
    }

    /**
     * @return the price
     */
    public double getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(double price) {
        this.price = price;
    }

}

部署时的异常堆栈跟踪如下,

  

2014-06-19T13:54:18.859 + 0530 |警告:部署失败   javax.xml.ws.WebServiceException:class   come.lets.learn.jaxws.jaxws.GetProductsv2Response没有   产品名称的属性   com.sun.xml.ws.server.sei.EndpointResponseMessageBuilder $ DocLit。(EndpointResponseMessageBuilder.java:258)     在   com.sun.xml.ws.server.sei.TieHandler.createResponseMessageBuilder(TieHandler.java:212)     在com.sun.xml.ws.server.sei.TieHandler。(TieHandler.java:117)     在com.sun.xml.ws.db.DatabindingImpl。(DatabindingImpl.java:110)   ...........由此引起:javax.xml.bind.JAXBException:产品不是   课堂上的有效财产   come.lets.learn.jaxws.jaxws.GetProductsv2Response at   com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:985)     在   com.sun.xml.ws.db.glassfish.JAXBRIContextWrapper.getElementPropertyAccessor(JAXBRIContextWrapper.java:120)     在   com.sun.xml.ws.server.sei.EndpointResponseMessageBuilder $ DocLit。(EndpointResponseMessageBuilder.java:254)     ... 61更多............. 2014-06-19T13:54:18.890 + 0530 |严重:   启动失败后清理期间的异常   org.apache.catalina.LifecycleException:Manager还没有   开始于   org.apache.catalina.session.StandardManager.stop(StandardManager.java:934)     在   org.apache.catalina.core.StandardContext.stop(StandardContext.java:6099)     在com.sun.enterprise.web.WebModule.stop(WebModule.java:720)   .................. 2014-06-19T13:54:18.890 + 0530 |严重:   ContainerBase.addChild:start:   org.apache.catalina.LifecycleException:java.lang.RuntimeException:   Servlet Web服务端点''失败   org.apache.catalina.core.StandardContext.start(StandardContext.java:5920)     在com.sun.enterprise.web.WebModule.start(WebModule.java:691)at   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1041)   ............由此引起:java.lang.RuntimeException:Servlet web   服务端点''失败   org.glassfish.webservices.WSServletContextListener.contextInitialized(WSServletContextListener.java:109)     在   org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:5362)   ..................引起:javax.xml.ws.WebServiceException:class   come.lets.learn.jaxws.jaxws.GetProductsv2Response没有   产品名称的属性   com.sun.xml.ws.server.sei.EndpointResponseMessageBuilder $ DocLit。(EndpointResponseMessageBuilder.java:258)     在   com.sun.xml.ws.server.sei.TieHandler.createResponseMessageBuilder(TieHandler.java:212)   ...........由此引起:javax.xml.bind.JAXBException:产品不是   课堂上的有效财产   come.lets.learn.jaxws.jaxws.GetProductsv2Response at   com.sun.xml.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:985)     在   com.sun.xml.ws.db.glassfish.JAXBRIContextWrapper.getElementPropertyAccessor(JAXBRIContextWrapper.java:120)   ............... 2014-06-19T13:54:18.890 + 0530 |警告:   java.lang.IllegalStateException:ContainerBase.addChild:start:   org.apache.catalina.LifecycleException:java.lang.RuntimeException:   Servlet Web服务端点''失败   java.lang.IllegalStateException:ContainerBase.addChild:start:   org.apache.catalina.LifecycleException:java.lang.RuntimeException:   Servlet Web服务端点''失败   org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:1044)     在   org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:1024)   ............. 2014-06-19T13:54:18.890 + 0530 |严重:异常时   调用类com.sun.enterprise.web.WebApplication start方法   java.lang.Exception:java.lang.IllegalStateException:   ContainerBase.addChild:start:org.apache.catalina.LifecycleException:   java.lang.RuntimeException:Servlet Web服务端点''失败     在   com.sun.enterprise.web.WebApplication.start(WebApplication.java:168)     在org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)     在org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)   ................... 2014-06-19T13:54:18.890 + 0530 |严重:例外   在生命周期处理java.lang.Exception期间:   java.lang.IllegalStateException:ContainerBase.addChild:start:   org.apache.catalina.LifecycleException:java.lang.RuntimeException:   Servlet Web服务端点''失败   com.sun.enterprise.web.WebApplication.start(WebApplication.java:168)     在org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)   ....................

0 个答案:

没有答案