axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <dava...@gmail.com>
Subject Re: "SAAJ0537: Invalid Content-Type" Exception
Date Wed, 13 Jul 2005 11:23:01 GMT
com.sun.xml.* means you are not using axis. Please ask the sun folks.

-- dims

On 7/13/05, Kumar <babloosony@gmail.com> wrote:
> Hi All,
> 
> I am using SAAJ and JAXM API implementations. When I send request soap
> message to the service I am getting back response soap message from the
> service but the client is abnormally terminating with exception  "SAAJ0537:
> Invalid Content-Type. Could be an error message instead of a SOAP message".
> The details are hereunder. 
> 
> Can anyone please tell me why I am getting this exception. As you see my
> client and service soap message consrtruction, I am using the same soap
> message for sending and receiving. Also, I see there are some junk
> characters like "179", "0" in my response soap message. I dont know why they
> are generated by JAXM/SAAJ API. 
> 
> 
> StandaloneClient.java
> --------------------------------------------------------------------------------------
> import java.util.*;
> import javax.xml.soap.*;
> import javax.xml.messaging.*;
> import javax.xml.parsers.* ;
> import org.xml.sax.*;
> import org.w3c.dom.*;
> import javax.xml.transform.*;
> import javax.xml.transform.dom.*;
> import javax.xml.transform.stream.*;
> import java.io.*;
> 
> public class StandaloneClient { 
> public static void main(String[] args) {
> try {
> SOAPConnectionFactory conFact =
> SOAPConnectionFactory.newInstance();
> SOAPConnection con = conFact.createConnection();
> 
> MessageFactory msgFact = MessageFactory.newInstance ();
> SOAPMessage msg = msgFact.createMessage();
> 
> SOAPPart soapPart=msg.getSOAPPart();
> SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
> 
> Name name = soapEnvelope.createName("GetWeatherReport", "wrp", "
> http://www.weatherreporter.com/wrp/");
> 
> SOAPBody soapBody=soapEnvelope.getBody();
> SOAPBodyElement soapBodyElement = soapBody.addBodyElement(name);
>  
> Name name2 = soapEnvelope.createName("message");
> SOAPElement soapElement = soapBodyElement.addChildElement(name2);
> soapElement.addTextNode("Sending Message...");
> 
> msg.saveChanges();
>  
> URLEndpoint url = new
> URLEndpoint("http://localhost:9999/ApServerWeb/MessageReceiver");
> 
> SOAPMessage response = con.call(msg, url); 
> SOAPPart resSoapPart = response.getSOAPPart();
> SOAPEnvelope resSoapEnvelope = resSoapPart.getEnvelope();
> 
> SOAPBody resSoapBody = resSoapEnvelope.getBody();
> if (resSoapBody.hasFault()) {
> SOAPFault soapFault = resSoapBody.getFault();
> System.out.println("Fault Cause " +
> soapFault.getFaultCode()+soapFault.getFaultString());
> }
> 
> Source source = resSoapPart.getContent();
> 
> TransformerFactory transfFact = TransformerFactory.newInstance ();
> Transformer transformer = transfFact.newTransformer();
> transformer.transform(source, new StreamResult(System.out));
> 
> con.close();
> }
> catch(Exception e) {
> e.printStackTrace();
> }
> }
> }
> 
>  
> 
> 
> 
> 
> MessageReceiver.java
> ---------------------------------------------------------------------------------------------
> import java.util.Iterator;
> import javax.servlet.ServletConfig;
> import javax.servlet.ServletException ;
> import javax.xml.messaging.JAXMServlet;
> import javax.xml.messaging.ReqRespListener;
> import javax.xml.soap.AttachmentPart;
> import javax.xml.soap.MessageFactory;
> import javax.xml.soap.Name;
> import javax.xml.soap.SOAPBody;
> import javax.xml.soap.SOAPBodyElement;
> import javax.xml.soap.SOAPElement;
> import javax.xml.soap.SOAPEnvelope;
> import javax.xml.soap.SOAPFactory;
> import javax.xml.soap.SOAPMessage;
> import javax.xml.soap.SOAPPart;
> 
> public class MessageReceiver extends JAXMServlet implements ReqRespListener
> {
> private MessageFactory messageFactory = null;
> 
> public void init(ServletConfig servletConfig) throws ServletException { 
> super.init(servletConfig);
> try {
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
> }
> 
> 
> public SOAPMessage onMessage(SOAPMessage message) {
> try {
> MessageFactory msgFact = MessageFactory.newInstance ();
> SOAPMessage msg = msgFact.createMessage();
> SOAPPart soapPart=msg.getSOAPPart();
> SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
> Name name = soapEnvelope.createName("GetWeatherReport", "wrp", "
> http://www.weatherreporter.com/wrp/");
> SOAPBody soapBody=soapEnvelope.getBody();
> SOAPBodyElement soapBodyElement = soapBody.addBodyElement(name);
> 
>  Name name2 = soapEnvelope.createName("message");
> SOAPElement soapElement = soapBodyElement.addChildElement(name2);
> soapElement.addTextNode("Sending Message...");
> msg.saveChanges();
> return msg; 
> }
> catch(Exception e) {
> e.printStackTrace();
> return null;
> }
> }
> }
> 
> 
> 
> 
> Request SOAP Message
> --------------------------------------------------------------------------------------------------
> POST /ApServerWeb/MessageReceiver HTTP/1.1
> Content-Type: text/xml; charset=utf-8
> Content-Length: 277
> SOAPAction: ""
> Cache-Control: no-cache
> Pragma: no-cache
> User-Agent: Java/1.4.2_04
> Host: 127.0.0.1:9999
> Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
> Connection: keep-alive
> 
> 
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="
> http://schemas.xmlsoap.org/soap/envelope/">
>    <SOAP-ENV:Header/>
>    <SOAP-ENV:Body>
>       <wrp:GetWeatherReport
> xmlns:wrp="http://www.weatherreporter.com/wrp/" >
>          <message>Sending Message...</message>
>       </wrp:GetWeatherReport>
>    </SOAP-ENV:Body></SOAP-ENV:Envelope>
> 
> 
> 
> 
> 
> Response SOAP Message
> --------------------------------------------------------------------------------------------------
> HTTP/1.1 200 OK
> Server: WebSphere Application Server/5.1
> Content-Type: text/html; charset=ISO-8859-1
> Content-Language: en-US
> Transfer-Encoding: chunked
> 
> 
> 179
> <soapenv:Envelope xmlns:soapenv="
> http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"> 
>    <soapenv:Body>  
>       <wrp:GetWeatherReport xmlns:wrp="
> http://www.weatherreporter.com/wrp/">   
>          <message xmlns="">Sending Message...</message>  
>       </wrp:GetWeatherReport> 
>    </soapenv:Body></soapenv:Envelope> 
> 0
> 
> 
> 
> 
> 
> 
> 
> Exception on Client Side
> --------------------------------------------------------------------------------------------------
> Jul 13, 2005 11:52:22 AM
> com.sun.xml.messaging.saaj.soap.MessageImpl
> identifyContentType
> SEVERE: SAAJ0537: Invalid Content-Type. Could be an error message instead of
> a SOAP message
> Jul 13, 2005 11:52:22 AM
> com.sun.xml.messaging.saaj.soap.MessageImpl <init>
> SEVERE: SAAJ0535: Unable to internalize message 
> com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> java.security.PrivilegedActionException:
> com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to
> internalize message
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call
> (HttpSOAPConnection.java:127)
>         at StandaloneClient.main(StandaloneClient.java:43)
> Caused by: java.security.PrivilegedActionException:
> com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to
> internalize message 
>         at
> java.security.AccessController.doPrivileged(Native Method)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:121)
>         ... 1 more
> Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl :
> Unable to internalize message
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:302)
>         at
> com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:47)
>         at
> com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:38)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java
> :354)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:150)
>         ... 3 more
> Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> Invalid Content-Type:text/html. Is this an error message instead of a SOAP
> response? 
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.identifyContentType(MessageImpl.java:398)
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:189)
>         ... 7 more
> 
>  CAUSE:
> 
> java.security.PrivilegedActionException:
> com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to
> internalize message
>         at
> java.security.AccessController.doPrivileged(Native Method)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call
> (HttpSOAPConnection.java:121)
>         at StandaloneClient.main(StandaloneClient.java:43)
> Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> Unable to internalize message
>         at com.sun.xml.messaging.saaj.soap.MessageImpl
> .<init>(MessageImpl.java:302)
>         at
> com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:47)
>         at
> com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage
> (SOAPMessageFactory1_1Impl.java:38)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:354)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run
> (HttpSOAPConnection.java:150)
>         ... 3 more
> Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> Invalid Content-Type:text/html. Is this an error message instead of a SOAP
> response?
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.identifyContentType
> (MessageImpl.java:398)
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:189)
>         ... 7 more
> 
> CAUSE:
> 
> java.security.PrivilegedActionException:
> com.sun.xml.messaging.saaj.SOAPExceptionImpl : Unable to
> internalize message
>         at
> java.security.AccessController.doPrivileged(Native Method)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:121)
>         at StandaloneClient.main(StandaloneClient.java:43)
> Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> Unable to internalize message
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java
> :302)
>         at
> com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:47)
>         at
> com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:38)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:354)
>         at
> com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(HttpSOAPConnection.java:150)
>         ... 3 more
> Caused by: com.sun.xml.messaging.saaj.SOAPExceptionImpl:
> Invalid Content-Type:text/html. Is this an error message instead of a SOAP
> response?
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.identifyContentType
> (MessageImpl.java:398)
>         at
> com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:189)
>         ... 7 more
> 
> 
> 
> 
> 
> 
> 
> Thanks & Regards,
> Kumar. 


-- 
Davanum Srinivas -http://blogs.cocoondev.org/dims/

Mime
View raw message