JAXB Marshsall问题Weblogic12c

问题描述 投票:4回答:3

问题

向12c和jaxb的应用程序迁移不起作用

说明

该应用程序当前在Weblogic 10上,并且使用了一些Web服务。我们使用HttpURLConnection将XML直接发布到Web服务。在发布之前,我们将请求编组,在收到响应后,我们将其解组]

该应用程序需要在12c上迁移,当我们在12c上测试该应用程序时,它无法正常工作。发送到Web服务的请求有所不同。请参见下面的架构,Java类和编组的请求

Refund.xsd
----------
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:avis="http://www.avis.com/XMLSchema" elementFormDefault="unqualified">
    <xsd:element name="RefundRequest">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="Request" avis:usage="ups"/>
                <xsd:element ref="DeliveryNumber" avis:usage="ups"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

<!-- Request and DeliveryNumber attributes her -->

使用Eclipse-> Generate-> JAxB类生成了Refund.java和相关类。在防火墙后面,并且在JAXB向导中确实要求我提供代理。我没有提供任何帮助。生成类

Refund.java

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "",propOrder = {
    "request",
    "barCodeDeliveryNumber"
})
@XmlRootElement(name = "TrackRequest")
public class RefundRequest{

    @XmlElement(name = "Request", required = true)
    protected Request request;
    @XmlElement(name = "DeliveryNumber", required = true)
    protected String deliveryNumber;

    /**
     * Gets the value of the request property.
     * 
     * @return
     *     possible object is
     *     {@link Request }
     *     
     */
    public Request getRequest() {
        return request;
    }

    /**
     * Sets the value of the request property.
     * 
     * @param value
     *     allowed object is
     *     {@link Request }
     *     
     */
    public void setRequest(Request value) {
        this.request = value;
    }

/**
 * Gets the value of the DeliveryNumber property.
 * 
 * @return
 *     possible object is
 *     {@link String }
 *     
 */
public String getDeliveryNumber() {
    return barCodeDeliveryNumber;
}

/**
 * Sets the value of the barCodeDeliveryNumber property.
 * 
 * @param value
 *     allowed object is
 *     {@link String }
 *     
 */
public void setDeliveryNumber(String value) {
    this.barCodeDeliveryNumber = value;
}

将对象编组为XML(请参见下文),然后将其传递给Web服务。 Web服务返回“格式不正确的XML”

应用程序库

javax.annotation_1.0.jar
javax.annotation_1.1.jar
javax.persistence_1.0.0.0_1-0.jar
javax.persistence_1.0.1.0_1-0.jar
javax.xml.bind_2.0.jar
javax.xml.bind_2.1.1.jar
jaxb-api.jar
jaxb-impl.jar
jaxws-api.jar
jaxws-rt.jar
jsr181-api.jar
jsr250-api.jar

使用jrockit160_29的Weblogic 12c

代码段

private static  Marshaller mreqinfo;
JAXBContext jxcreq =JAXBContext.newInstance(RefundRequest.class.getPackage().getName());
             mreqinfo=jxcreq.createMarshaller();

mreqinfo.marshall(refundRequestObj)

[查看日志,我可以看到在weblogic 12c上编组后的请求。我认为这是造成问题的xmlns:ns0 =“”

* *编组请求-在weblogic 12c jrockit160_29中尝试时不起作用。**

需要摆脱xmlns:ns0 =“”

<?xml version="1.0" encoding="UTF-8"?>
<RefundRequest  xmlns:ns0="">
    <Request>
        <TransactionReference>
            <CustomerContext>YILE00010208201120.04.08.4|11/22/2013 12:28:31:085</CustomerContext>
        </TransactionReference>
        <RequestAction>Refund</RequestAction>
    </Request>
    <DeliveryNumber>974869</DeliveryNumber>
</RefundRequest>

*** Weblogic 10中的编组请求(weblogic 10 jrockit160_29中的现有工作版本)>


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RefundRequest>
    <Request>
        <TransactionReference>
            <CustomerContext>YILE00010208201120.04.08.4|11/22/2013 12:28:31:085</CustomerContext>
        </TransactionReference>
        <RequestAction>Refund</RequestAction>
    </Request>
    <DeliveryNumber>974869</DeliveryNumber>
</RefundRequest>

正在将应用程序迁移到12c并且jaxb无法正常工作说明该应用程序当前在Weblogic 10上,并且消耗了一些Web服务。我们将XML直接发布到Web服务...

web-services jaxb marshalling httpurlconnection
3个回答
1
投票

在您使用EclipseLink JAXB (MOXy)的WebLogic 12.1.1中,将其用作默认的JAXB (JSR-222)提供程序(请参阅:http://blog.bdoughan.com/2011/12/eclipselink-moxy-is-jaxb-provider-in.html)。您遇到的问题是由于自EclipseLink 2.3.3发行版(当前发行版是EclipseLink 2.5.1)以来已修复的错误。

以下是有关在WebLogic中使用较新版本的EclipseLink的说明的链接:


0
投票

要解决此问题,您可以通过覆盖Weblogic 12c中的jaxb jar,添加自己的jaxb jar(jaxb-core.jar,jaxb-impl.jar)。您可以通过在WEB-INF / lib下的战争中放置自己的jaxb jar并通过使用preferred-web-inf-classes元素标签配置weblogic.xml来实现。然后将weblogic.xml放在您的战争的WEB-INF目录下


0
投票

具有相同的问题:JAXB放置诸如之类的前缀。通过将prefer-application-resources

© www.soinside.com 2019 - 2024. All rights reserved.