首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JAXB Marshsall发行Weblogic12c

JAXB Marshsall发行Weblogic12c
EN

Stack Overflow用户
提问于 2013-11-22 18:03:44
回答 3查看 8.2K关注 0票数 4

问题

应用程序迁移到12c,jaxb不工作。

描述

该应用程序目前在Weblogic 10上,并使用一些and服务。我们使用HttpURLConnection直接将XML发布到We服务。在发帖之前,我们将请求编组,在收到答复后,我们取消对他们的答复。

这个应用程序需要在12c上迁移,当我们在12c上测试应用程序时,它的工作方式不一样。发送到webservice的请求有一个difference.Please,请参见下面的模式、java类和封送请求。

代码语言:javascript
复制
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

代码语言:javascript
复制
@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格式不佳“

App库

代码语言:javascript
复制
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的WebLogic12c

代码段

代码语言:javascript
复制
private static  Marshaller mreqinfo;
JAXBContext jxcreq =JAXBContext.newInstance(RefundRequest.class.getPackage().getName());
             mreqinfo=jxcreq.createMarshaller();

mreqinfo.marshall(refundRequestObj)

查看日志,我可以看到weblogic 12c上的封送请求。有一个xmlns:ns0="",我认为这是造成问题的原因

**编组请求-在WebLogic12c jrockit160_29 .**中尝试时不工作

需要摆脱xmlns:ns0=“

代码语言:javascript
复制
<?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中现有的工作版本)

代码语言:javascript
复制
<?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>
EN

回答 3

Stack Overflow用户

发布于 2013-11-26 21:39:01

在您正在使用的WebLogic 12.1.1中,EclipseLink JAXB (MOXy)被用作默认的JAXB (JSR-222)提供程序(参见:http://blog.bdoughan.com/2011/12/eclipselink-moxy-is-jaxb-provider-in.html)。您遇到的问题是由于EclipseLink 2.3.3发行版(当前版本为EclipseLink 2.5.1)中已经修复了一个bug。

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

  • http://blog.bdoughan.com/2012/10/updating-eclipselink-in-weblogic.html

如果您是Oracle支持客户,那么您可以与他们通信以请求解决此问题的官方修补程序。

票数 1
EN

Stack Overflow用户

发布于 2014-03-21 17:26:56

要解决这个问题,您可以通过在Weblogic 12c中重写jaxb jars来添加您自己的jaxb jars (jaxb-core.jar、jaxb-in-.jar)。您可以将自己的jaxb war放入war中,在web/lib下进行配置,并使用weblogic.xml元素标记配置jaxb war。然后将weblogic.xml放在war的WEB目录下。

首选-web-inf-classes元素 weblogic.xml网络应用程序部署描述符包含一个元素(该元素的子元素)。默认情况下,此元素设置为False。将此元素设置为True可以颠覆类加载器委托模型,以便优先加载来自Web应用程序的类定义,而不是在更高级别的类加载器中加载类定义。这允许网络应用程序使用自己版本的第三方类,这也可能是WebLogic服务器的一部分。

有关详细信息,请参阅此链接01/wls/docs90/programming/classloading.html

weblogic.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.</wls:weblogic-version>
<wls:container-descriptor>
    <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
<wls:container-descriptor>
    <wls:show-archived-real-path-enabled>true</wls:show-archived-real-path-enabled>
</wls:container-descriptor>
<wls:context-root>your_context_root_name</wls:context-root>

票数 0
EN

Stack Overflow用户

发布于 2019-10-03 15:09:25

同样的问题是: JAXB放置像< ns0:TagName>这样的前缀。通过在weblogic-application.xml中添加首选应用程序资源来解决问题

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
    <prefer-application-resources>
       <resource-name>META-INF/services/javax.xml.bind.*</resource-name>
    </prefer-application-resources>
</weblogic-application>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20151553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档