Reputation: 868
Currently our cXML Punchout implementation (SAP hybris standard) does not print the Doctype on a response.
The the endsyste needs it:
Wed Sep 02 00:19:42 PDT 2020 (T12:prealm_1234:global\c1234:PasswordAdapter1:db2wer:C123_UI1)
(application.cxml:ERROR) [ID1234]: CXMLDOMRequester: Unable to parse cXML response with error:
org.xml.sax.SAXParseException: Document root element "cXML", must match DOCTYPE root "null".
I tried to do some research:
One request goes to de.hybris.platform.b2bpunchoutaddon.controllers.pages.DefaultPunchOutSetUpController.handlePunchOutSetUpRequest()
and it returns a CXML Object. This Object goes through some mapper and converter, but it adds no where the Doctype.
Then I found de.hybris.platform.b2bpunchoutaddon.converter.CXMLJaxb2MessageConverter
. This MessageConverter
adds the Doctype to the xml header. But it never runs.
For me the spring configuration looks correct:
<alias name="cXMLJaxb2MessageConverter" alias="jaxbMessageConverter" />
<bean id="cXMLJaxb2MessageConverter" class="de.hybris.platform.b2bpunchoutaddon.converter.CXMLJaxb2MessageConverter"/>
Right now I despair on this problem. Does any of you know how to fix it?
Upvotes: 0
Views: 671
Reputation: 101
This is because in your storefront extension you have the following setting of message converters:
<!-- activates annotation driven binding -->
<mvc:annotation-driven ignore-default-model-on-redirect="true" validator="validator">
<mvc:message-converters>
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</mvc:message-converters>
</mvc:annotation-driven>
so, this spring config will of course ignore the bean which your b2bpunchoutaddon creates
<alias name="cXMLJaxb2MessageConverter" alias="jaxbMessageConverter" />
<bean id="cXMLJaxb2MessageConverter" class="de.hybris.platform.b2bpunchoutaddon.converter.CXMLJaxb2MessageConverter"/>
My fix for this was to use change my storefront spring mvc config to use bean with the id="jaxbMessageConverter" instead of an inline bean:
<bean id="jaxbMessageConverter" class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/>
<!-- activates annotation driven binding -->
<mvc:annotation-driven ignore-default-model-on-redirect="true" validator="validator">
<mvc:message-converters>
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
<ref bean="jaxbMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</mvc:message-converters>
</mvc:annotation-driven>
Now, we know that the alias will work and the response will contain the doctype:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.024/cXML.dtd">
<cXML payloadID="1609762719111.6059@DESKTOP-3HR841G" timestamp="2021-01-04T14:18:39+02:00" xml:lang="en-US">
<Response>
<Status code="200" text="success"/>
<PunchOutSetupResponse>
<StartPage>
<URL>foo.bar.bla</URL>
</StartPage>
</PunchOutSetupResponse>
</Response>
</cXML>
Upvotes: 0