soap - How to prevent Java21 to forcibly add 'ns2' to namespace? - Stack Overflow

I have a Java application doing SOAP requests to a WebService (which I have no control of). It is curre

I have a Java application doing SOAP requests to a WebService (which I have no control of). It is currently running on Java8 and I need to make it compatible for both, Java8 and Java21 (not only Java21).

Otherwise I have been able to make the app compatible on both, but I am facing this weird problem where this SOAP request seems to be invalid and with JRE21. For now, I think the reason is that 'ns2' is forcibly added to the soap requests:

  • jre8: soap:Body<DDataSendReq -> works
  • jre21: soap:Body<ns2:DDataSendReq -> error

Also: When I run this in Eclipse with JRE21, it works but when I make JAR package, then it won't.

I have tried these solutions (most common suggestions for this type of problem): (eg. these)

  • edit package-info.java by (setting the prefix to "")
  • creating a custom NamespacePrefixMapper where the prefix is set to ""
  • deleting the package-info.java

But no luck... Any suggestions where to go next and what to try? Is this just something that comes as a gift with javax -> jakarta stuff and it is not possible to support both jre 8/21?

Here is some debug log from working scenario (with jre8):

INFO: Outbound Message
---------------------------
ID: 1
Address:  
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d"; start="<[email protected]>"; start-info="text/xml"
Headers: {Accept=[*/*], Connection=[Keep-Alive], SOAPAction=["SendAction"]}
Payload: 
--uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="/"><soap:Body><DDataSendReq xmlns=";><Language>en</Language><ReportingMaterial><xop:Include xmlns:xop="; href="cid:[email protected]"/></ReportingMaterial></DDataSendReq></soap:Body></soap:Envelope>
--uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="VENU.txt"

VENU    231278........

--uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d--



INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116"; start="<[email protected]>"; start-info="text/xml"
Headers: {connection=[keep-alive], content-type=[multipart/related; type="application/xop+xml"; boundary="uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116"; start="<[email protected]>"; start-info="text/xml"], ........}
Payload: 
--uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="/"><soap:Body><DDataSendResp xmlns=";><Result><Filing>VENU.txt</Filing><Accepted>true</Accepted><Timestamp>2025-03-04T16:13:19.560+02:00</Timestamp></Result><CheckupResult><xop:Include xmlns:xop="; href="cid:[email protected]"/></CheckupResult></DDataSendResp></soap:Body></soap:Envelope>
--uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="7015949_Result_8005669487209363021.xml"

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><TMResult xmlns=";><CheckupResult filing="VENU.txt" reports="2" correct="2" errors="0">Ok</CheckupResult></TMResult>
--uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116--
--------------------------------------

Here is some debug log from non-working scenario (with jre21):

INFO: Outbound Message
---------------------------
ID: 1
Address: 
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211"; start="<[email protected]>"; start-info="text/xml"
Headers: {Accept=[*/*], Connection=[Keep-Alive], SOAPAction=["SendAction"]}
Payload: 
--uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="/"><soap:Body><ns2:DDataSendReq xmlns:ns2=";><Language>en</Language><ReportingMaterial><xop:Include xmlns:xop="; href="cid:[email protected]"/></ReportingMaterial></ns2:DDataSendReq></soap:Body></soap:Envelope>
--uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="VENU.txt"

VENU    231278........

--uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211--



INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 500
Encoding: ISO-8859-1
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba"; start="<[email protected]>"; start-info="text/xml"
Headers: {connection=[close], content-type=[multipart/related; type="application/xop+xml"; boundary="uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba"; start="<[email protected]>"; start-info="text/xml"], ........}
Payload: 
--uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Error: unexpected text "VkVST05VTU.......gDQo=" </faultstring></soap:Fault></soap:Body></soap:Envelope>
--uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba--
--------------------------------------

EDIT: Starting to think that this might have something to do with how the app is built and run with JRE9+ that the package-info.java has no effect at all what so ever -> will try to investigate this idea more. Or maybe this is just javax/jakarta mess that might not be resolvable to work on both JRE.

EDIT2: Getting clueless... Just spent few weeks to update Hibernate from 4 -> 6 as there were some dependencies and I thought that it would cause some javax-dependencies to exist there. No more javax but still the same issue.. I'm clueless now.

I have a Java application doing SOAP requests to a WebService (which I have no control of). It is currently running on Java8 and I need to make it compatible for both, Java8 and Java21 (not only Java21).

Otherwise I have been able to make the app compatible on both, but I am facing this weird problem where this SOAP request seems to be invalid and with JRE21. For now, I think the reason is that 'ns2' is forcibly added to the soap requests:

  • jre8: soap:Body<DDataSendReq -> works
  • jre21: soap:Body<ns2:DDataSendReq -> error

Also: When I run this in Eclipse with JRE21, it works but when I make JAR package, then it won't.

I have tried these solutions (most common suggestions for this type of problem): (eg. these)

  • edit package-info.java by (setting the prefix to "")
  • creating a custom NamespacePrefixMapper where the prefix is set to ""
  • deleting the package-info.java

But no luck... Any suggestions where to go next and what to try? Is this just something that comes as a gift with javax -> jakarta stuff and it is not possible to support both jre 8/21?

Here is some debug log from working scenario (with jre8):

INFO: Outbound Message
---------------------------
ID: 1
Address:  https://foo.bar/wsapp/atp
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d"; start="<[email protected]>"; start-info="text/xml"
Headers: {Accept=[*/*], Connection=[Keep-Alive], SOAPAction=["SendAction"]}
Payload: 
--uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap./soap/envelope/"><soap:Body><DDataSendReq xmlns="http://www.cust/xmlschema/AT"><Language>en</Language><ReportingMaterial><xop:Include xmlns:xop="http://www.w3./2004/08/xop/include" href="cid:[email protected]"/></ReportingMaterial></DDataSendReq></soap:Body></soap:Envelope>
--uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="VENU.txt"

VENU    231278........

--uuid:ea54dfe5-04ca-4460-9ff4-ad610267c77d--



INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116"; start="<[email protected]>"; start-info="text/xml"
Headers: {connection=[keep-alive], content-type=[multipart/related; type="application/xop+xml"; boundary="uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116"; start="<[email protected]>"; start-info="text/xml"], ........}
Payload: 
--uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap./soap/envelope/"><soap:Body><DDataSendResp xmlns="http://www.cust/xmlschema/AT"><Result><Filing>VENU.txt</Filing><Accepted>true</Accepted><Timestamp>2025-03-04T16:13:19.560+02:00</Timestamp></Result><CheckupResult><xop:Include xmlns:xop="http://www.w3./2004/08/xop/include" href="cid:[email protected]"/></CheckupResult></DDataSendResp></soap:Body></soap:Envelope>
--uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="7015949_Result_8005669487209363021.xml"

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?><TMResult xmlns="http://www.cust/xmlschema/TMR"><CheckupResult filing="VENU.txt" reports="2" correct="2" errors="0">Ok</CheckupResult></TMResult>
--uuid:d2089dd1-82a3-4ec2-86ed-b4a61864b116--
--------------------------------------

Here is some debug log from non-working scenario (with jre21):

INFO: Outbound Message
---------------------------
ID: 1
Address: https://foo.bar/wsapp/atp
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211"; start="<[email protected]>"; start-info="text/xml"
Headers: {Accept=[*/*], Connection=[Keep-Alive], SOAPAction=["SendAction"]}
Payload: 
--uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap./soap/envelope/"><soap:Body><ns2:DDataSendReq xmlns:ns2="http://www.cust/xmlschema/AT"><Language>en</Language><ReportingMaterial><xop:Include xmlns:xop="http://www.w3./2004/08/xop/include" href="cid:[email protected]"/></ReportingMaterial></ns2:DDataSendReq></soap:Body></soap:Envelope>
--uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
Content-Disposition: attachment;name="VENU.txt"

VENU    231278........

--uuid:9c5f8d34-c322-4517-a9d1-7e5be0144211--



INFO: Inbound Message
----------------------------
ID: 1
Response-Code: 500
Encoding: ISO-8859-1
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba"; start="<[email protected]>"; start-info="text/xml"
Headers: {connection=[close], content-type=[multipart/related; type="application/xop+xml"; boundary="uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba"; start="<[email protected]>"; start-info="text/xml"], ........}
Payload: 
--uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap./soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Error: unexpected text "VkVST05VTU.......gDQo=" </faultstring></soap:Fault></soap:Body></soap:Envelope>
--uuid:47ab21a0-b580-4c36-92ad-f0f24f8e13ba--
--------------------------------------

EDIT: Starting to think that this might have something to do with how the app is built and run with JRE9+ that the package-info.java has no effect at all what so ever -> will try to investigate this idea more. Or maybe this is just javax/jakarta mess that might not be resolvable to work on both JRE.

EDIT2: Getting clueless... Just spent few weeks to update Hibernate from 4 -> 6 as there were some dependencies and I thought that it would cause some javax-dependencies to exist there. No more javax but still the same issue.. I'm clueless now.

Share Improve this question edited 2 days ago Jokkeri asked Mar 6 at 11:37 JokkeriJokkeri 1,0551 gold badge16 silver badges38 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try this please and let me know if it works: In your package-info (in the package where your JAXB classes live) ensure you have something like:

@XmlSchema(
  namespace = "http://www.cust/xmlschema/AT",
  elementFormDefault = XmlNsForm.QUALIFIED,
  xmlns = { @XmlNs(prefix = "", namespaceURI = "http://www.cust/xmlschema/AT") }
)
package your.generated.package;

import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744978915a4604317.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信