[mule-user] Need help on [Unsupported Content-Type: text/plain; charset=UTF-8]

542 views
Skip to first unread message

Hsien Soon Fua

unread,
Aug 2, 2010, 6:01:55 AM8/2/10
to us...@mule.codehaus.org
hi, need some help here. i want to input a string and expose to a websevice. below are my configuration

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd">

<model name="sample">
<service name="inputService">
<inbound>
<inbound-endpoint address="stdio://System.in?promptMessage=Please Enter a String:"
synchronous="true" >

</inbound-endpoint>
</inbound>
<outbound>
<chaining-router>
<outbound-endpoint address="http://localhost:8080/Services/test?WSDL;method=getName"
synchronous="true"/>
<outbound-endpoint address="stdio://System.out"/>
</chaining-router>
</outbound>
</service>
</model>
</mule>


below are the error msg that i get on my glassfish , it seem like the UTF -8 cause the problem... any idea to solve this error?

Unsupported Content-Type: text/plain; charset=UTF-8 Supported ones are: [text/xml]
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/plain; charset=UTF-8 Supported ones are: [text/xml]
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:291)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:128)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:287)
at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:276)
at com.sun.xml.ws.transport.http.HttpAdapter.access$500(HttpAdapter.java:93)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:432)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
at com.sun.enterprise.webservice.JAXWSServlet.doPost(JAXWSServlet.java:177)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


David Dossot

unread,
Aug 2, 2010, 11:46:45 AM8/2/10
to us...@mule.codehaus.org
I don't think the issue comes from the UTF-8 encoding:


Unsupported Content-Type: text/plain; charset=UTF-8 Supported ones are: [text/xml]

I think it's using text/plain that is the issue. Add a message properties transformer to the HTTP outbound to set Content-Type to text/xml.

HTH
D.

Hsien Soon Fua

unread,
Aug 2, 2010, 9:47:54 PM8/2/10
to us...@mule.codehaus.org
Hi david, thank for your reply, i added this to my inbound-endpoint

<message-properties-transformer name="add-xml-content-type-header" >

<add-message-property key="Content-Type" value="text/xml" />

</message-properties-transformer>

but the server return

Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
at com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:574)
at com.sun.xml.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:92)
at com.sun.xml.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:76)
... 42 more

any idea on this ?

David Dossot

unread,
Aug 2, 2010, 10:39:42 PM8/2/10
to us...@mule.codehaus.org
Sorry, I should have caught that earlier but what's happening is that, with the current configuration, you are passing the String as it is entered on the console to the remote web service, i.e. it is not wrapped into a SOAP envelope...

In your case, you want to use the WSDL connector (http://www.mulesoft.org/documentation/display/MULE2USER/WSDL+Connectors):

<outbound-endpoint address="wsdl:http://localhost:8080/Services/test?WSDL;method=getName" synchronous="true"/>

HTH
D.

Hsien Soon Fua

unread,
Aug 2, 2010, 11:27:52 PM8/2/10
to us...@mule.codehaus.org
thank for enlighten, but when i add wdsl, i get this error msg, just after i input a string and hit enter...

ERROR 2010-08-03 11:16:02,307 [connector.stdio.0.receiver.1] org.mule.service.DefaultServiceExceptionStrategy:
********************************************************************************
Message : Initialisation Failure: Failed to create service.
Type : org.mule.retry.RetryPolicyExhaustedException
Code : MULE_ERROR-84
JavaDoc : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/retry/RetryPolicyExhaustedException.html
Object : endpoint.outbound.http://localhost:8080/Services/test?WSDL;method=getName
********************************************************************************
Exception stack is:
1. WSDLException (at /html): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'. (javax.wsdl.WSDLException)
com.ibm.wsdl.xml.WSDLReaderImpl:-1 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/wsdl/WSDLException.html)
2. Failed to create service. (org.apache.cxf.service.factory.ServiceConstructionException)
org.apache.cxf.wsdl11.WSDLServiceFactory:68 (null)
3. Initialisation Failure: Failed to create service. (org.mule.retry.RetryPolicyExhaustedException)
org.mule.retry.policies.AbstractPolicyTemplate:97 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/retry/RetryPolicyExhaustedException.html)
********************************************************************************
Root Exception stack trace:
javax.wsdl.WSDLException: WSDLException (at /html): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.
at com.ibm.wsdl.xml.WSDLReaderImpl.checkElementName(Unknown Source)


any idea ? my souce code is modify from the wsdl connector sample ... do i miss out anything ?

David Dossot

unread,
Aug 2, 2010, 11:45:55 PM8/2/10
to us...@mule.codehaus.org
Does http://localhost:8080/Services/test?WSDL return a valid WSDL?

I also notice that the & has been replaced with a , in your endpoint config, the good one is:

<outbound-endpoint address="wsdl:http://localhost:8080/Services/test?WSDL&method=getName" synchronous="true"/>

D.

Hsien Soon Fua

unread,
Aug 3, 2010, 12:19:12 AM8/3/10
to us...@mule.codehaus.org
Yes.. it return a valid WSDL,

after i replace the code with & in

<outbound-endpoint address="wsdl:http://localhost:8080/Services/test?WSDL&method=getName" synchronous="true"/>

and i get this error msg when i run it , it seem like need to include ; to entity "method".

ERROR 2010-08-03 12:09:55,088 [main] org.mule.MuleServer:
********************************************************************************
Message : Initialisation Failure: Line 34 in XML document from URL [file:/C:/workspace/EConnect/conf/echo-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The reference to entity "method" must end with the ';' delimiter.
Type : org.mule.api.lifecycle.InitialisationException
Code : MULE_ERROR-72085
JavaDoc : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/InitialisationException.html
Object : org.mule.config.spring.SpringRegistry@2f48d2
********************************************************************************
Exception stack is:
1. The reference to entity "method" must end with the ';' delimiter. (org.xml.sax.SAXParseException)
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper:-1 (null)
2. Line 34 in XML document from URL [file:/C:/workspace/EConnect/conf/echo-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The reference to entity "method" must end with the ';' delimiter. (org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader:404 (null)
3. Initialisation Failure: Line 34 in XML document from URL [file:/C:/workspace/EConnect/conf/echo-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The reference to entity "method" must end with the ';' delimiter. (org.mule.api.lifecycle.InitialisationException)
org.mule.registry.AbstractRegistry:76 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/InitialisationException.html)


********************************************************************************
Root Exception stack trace:

org.xml.sax.SAXParseException: The reference to entity "method" must end with the ';' delimiter.

Hsien Soon Fua

unread,
Aug 3, 2010, 12:33:04 AM8/3/10
to us...@mule.codehaus.org
erm , i just replace it to &amp;method and it seem like working ... and i get another error ... i try figure it out first ...

Hsien Soon Fua

unread,
Aug 3, 2010, 3:30:36 AM8/3/10
to us...@mule.codehaus.org
it seem like working ... but somehow i dun know wut gone wrong... is this my mule configuration or webservice problem ? mule working but not the webservice ? but it is a valid WSDL.... i add environment variable also cant work ... any idea?

Aug 3, 2010 2:48:05 PM org.apache.cxf.endpoint.dynamic.DynamicClientFactory outputDebug
INFO: Created classes: com.safeguard.webserver.GetName, com.services.test.GetNameResponse, com.safeguard.webserver.ObjectFactory
[ERROR] IOException during exec() of compiler "javac". Check your path environment variable.
Aug 3, 2010 2:48:05 PM org.apache.cxf.endpoint.dynamic.DynamicClientFactory createClient
SEVERE: Could not compile java files for http://localhost:8080/Services/test?WSDL.)

Root Exception was: "com.services.test" doesnt contain ObjectFactory.class or jaxb.index. Type: class javax.xml.bind.JAXBException

********************************************************************************
Message : Initialisation Failure: Unable to create JAXBContext for generated packages: "com.services.test" doesnt contain ObjectFactory.class or jaxb.index


Type : org.mule.retry.RetryPolicyExhaustedException
Code : MULE_ERROR-84
JavaDoc : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/retry/RetryPolicyExhaustedException.html

Object : endpoint.outbound.http://localhost:8080/Services/test?WSDL&method=getName
********************************************************************************
Exception stack is:
1. "com.safeguard.webserver" doesnt contain ObjectFactory.class or jaxb.index (javax.xml.bind.JAXBException)
com.sun.xml.bind.v2.ContextFactory:183 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/xml/bind/JAXBException.html)
2. Unable to create JAXBContext for generated packages: "com.services.test" doesnt contain ObjectFactory.class or jaxb.index (java.lang.IllegalStateException)
org.apache.cxf.endpoint.dynamic.DynamicClientFactory:259 (null)
3. Initialisation Failure: Unable to create JAXBContext for generated packages: "com.services.test" doesnt contain ObjectFactory.class or jaxb.index (org.mule.retry.RetryPolicyExhaustedException)
org.mule.retry.policies.AbstractPolicyTemplate:97 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/retry/RetryPolicyExhaustedException.html)


********************************************************************************
Root Exception stack trace:

javax.xml.bind.JAXBException: "com.services.test" doesnt contain ObjectFactory.class or jaxb.index

David Dossot

unread,
Aug 3, 2010, 12:42:19 PM8/3/10
to us...@mule.codehaus.org
Googling shows it's a pretty common problem. See this: http://www.mail-archive.com/cxf-...@incubator.apache.org/msg01865.html

Are you sure that "javac (the bin directory of your SDK installation) is on your PATH?"

D.

Hsien Soon Fua

unread,
Aug 3, 2010, 10:25:47 PM8/3/10
to us...@mule.codehaus.org
Haha, i miss out the PATH that you mention ... finally it work .... thank a lot david ...... ^^

Ronnie Downing

unread,
Oct 11, 2011, 2:15:14 PM10/11/11
to us...@mule.codehaus.org
David, I know this is an old thread, but I'm having a heckuva time calling out to an external web service and having access to the results, maybe even passing them to the next flow, with Mule 3. http://www.mulesoft.org/documentation/display/MULE2USER/WSDL+Connectors may work for Mule 2, but it doesn't appear to work for Mule 3. Where can I find and example of a call to an external web service and then have the response payload available for processing by downstream flows, in Mule 3? Thanks!

David Dossot

unread,
Oct 11, 2011, 2:36:39 PM10/11/11
to us...@mule.codehaus.org
Ronnie,

The WSDL connector should work fine with Mule 3: http://www.mulesoft.org/documentation/display/MULE3USER/WSDL+Connectors I've found a couple integration tests that exercise it :)

If this connector doesn't work for you (I think it has limited or even no support for complex objects interchange), use that: http://www.mulesoft.org/documentation/display/MULE3USER/Consuming+Web+Services+with+CXF

HTH
David
Reply all
Reply to author
Forward
0 new messages