Here is the concerned extract of my sitemap :
<map:pipeline>
<map:generate type="stream">
<map:parameter name="defaultContentType" value="text/xml"/>
</map:generate>
<map:match pattern="tentative">
<map:transform type="testTransformer" />
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
Here, a part of the applicationContext.xml (Spring declaration of my
transformer) :
<bean name="testService"
class="
org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="maTransactionManager" />
</property>
<property name="target">
<bean class="xxxx.TestService">
<property name="maxml2ObjectsService">
<ref bean="maxml2ObjectsService" />
</property>
<property name="serviceProgramsService">
<ref bean="serviceProgramsService" />
</property>
</bean>
</property>
<property name="transactionAttributes">
<props>
<prop key="test">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="testTransformer"
name="org.apache.cocoon.transformation.Transformer/testTransformer"
scope="prototype"
class="xxxx.TestTransformer">
<property name="testService">
<ref bean="testService"/>
</property>
</bean>
What I had in my transformer to log the XML stream (wich is effectively
received and logged by the transformer) :
public Document transform(Document document) {
try {
DOMSource domSource = new DOMSource(document);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
log.debug("TRANSFORMATION:" + writer.toString());
}
catch (TransformerConfigurationException e) {
e.printStackTrace();
}
catch (TransformerException e) {
e.printStackTrace();
}
return document;
}
I use HttpClient to send the post request containing the XML stream and to
get the XML stream received (unhappily NULL) :
HttpClient client = new HttpClient();
StringBuffer newUrl = new StringBuffer();
newUrl.append(url);
PostMethod method = new PostMethod(newUrl.toString());
method.setRequestBody(new FileInputStream(xmlFile));
String xml = post.getResponseBodyAsString();
System.out.println("Exported virtual XML : " + maxml); // Here the
response is NULL
Thank for your help
2007/11/16, warrell harries <[EMAIL PROTECTED]>:
>
> Hi Jean-Claude,
>
> What generator are you using in your pipeline match? Can you show us the
> sitemap? You would need to use the Request generator or another one that
> 'loads' the pipeline with the contents of the HTTP Request.
>
> Cheers
>
> On 16/11/2007, Jean-Claude Vogel <[EMAIL PROTECTED]> wrote:
> >
> > Hello guys,
> >
> > I would like to write my own dom transformer. So I simply wrote the
> > following in order to get firstly an identity transformer :
> >
> > public class TestTransformer extends AbstractDOMTransformer {
> > private Request request;
> >
> > public void setup(SourceResolver resolver, Map objectModel,
> > String src, Parameters par)
> > throws ProcessingException, SAXException,
> > IOException {
> > super.setup(resolver, objectModel, src, par);
> > }
> >
> > public Document transform(Document document) {
> > // When I log here I see that "document" contains what I
> > want it to contain
> > return document;
> > }
> > }
> >
> >
> > To test I send an HTTP post request with an XML in its body, but I my
> > HTTP request response body is desesperatly NULL.
> >
> > I tried to log what happens in the transform method and I can see in my
> > XML body sent by HTTP. The post response is ever empty.
> >
> > What's wrong in my code please ?
> >
>
>