Web services JAXB Marshall问题Weblogic12c 问题

Web services JAXB Marshall问题Weblogic12c 问题,web-services,jaxb,marshalling,httpurlconnection,Web Services,Jaxb,Marshalling,Httpurlconnection,应用程序迁移到12c和jaxb不起作用 描述 该应用程序当前位于Weblogic 10上,并使用一些Web服务。我们使用HttpURLConnection将XML直接发布到Web服务。在发布之前,我们封送请求,在收到响应之后,我们取消封送请求 该应用程序需要在12c上进行迁移,当我们在12c上测试该应用程序时,它的工作原理是不一样的。发送到Web服务的请求有所不同。请参见下面的模式、java类和封送请求 Refund.xsd ---------- <?xml version="1.0" e

应用程序迁移到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 -->
我将对象编组为XML(见下文)并将其传递给web服务。Web服务返回“XML格式不正确”

应用程序库 使用jrockit160_29的Weblogic 12c

代码片段 查看日志,我可以看到WebLogic12c上的以下封送请求。 有一个xmlns:ns0=“”,我认为这是造成问题的原因

**封送请求-在weblogic 12c jrockit160_29中尝试时无法工作 .*

需要摆脱xmlns:ns0=“”


YILE00010208201120.04.08.4 | 11/22/2013 12:28:31:085
退款
974869
***Weblogic 10中的封送请求(Weblogic 10 JRockit16029中的现有工作版本



YILE00010208201120.04.08.4 | 11/22/2013 12:28:31:085
退款
974869

您正在使用的WebLogic 12.1.1中的默认提供程序(请参阅:)。您遇到的问题是由于EclipseLink 2.3.3版本(当前版本为EclipseLink 2.5.1)中修复了一个错误

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


如果您是Oracle支持客户,那么您可以与他们沟通,请求对此问题的正式补丁。

要解决此问题,您可以添加自己的jaxb jar(jaxb-core.jar,jaxb impl.jar)通过覆盖Weblogic 12c中的jaxb JAR,您可以将自己的jaxb JAR放在war的WEB-INF/lib下,并使用首选WEB-INF类元素标记配置Weblogic.xml。然后将Weblogic.xml放在war的WEB-INF目录下

首选web inf类元素

weblogic.xml Web应用程序部署描述符包含 元素(元素的子元素) 元素)。默认情况下,此元素设置为 False。将此元素设置为True会破坏类加载器 委托模型,以便从Web应用程序中定义类 优先于更高级别中的类定义加载 这允许Web应用程序使用自己版本的 第三方类,也可能是WebLogic Server的一部分

有关更多详细信息,请参阅此链接

weblogic.xml

<?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>

12.1.
真的
真的
您的\u上下文\u根\u名称

也有同样的问题:JAXB放置前缀,如。 通过向weblogic application.xml添加首选应用程序资源来解决此问题:

<?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>

META-INF/services/javax.xml.bind*
private static  Marshaller mreqinfo;
JAXBContext jxcreq =JAXBContext.newInstance(RefundRequest.class.getPackage().getName());
             mreqinfo=jxcreq.createMarshaller();

mreqinfo.marshall(refundRequestObj)
<?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>
<?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>
<?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>
<?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>