Register FAQ Calendar Search Today's Posts Mark Forums Read

Go Back   Java Programming Forums > Data Manipulation > XML

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 29-06-2008, 03:39 PM
Junior Member
 
Join Date: Jun 2008
Location: Pretoria, South Africa
Posts: 4
Buglish is on a distinguished road
Send a message via MSN to Buglish Send a message via Yahoo to Buglish Send a message via Skype™ to Buglish
Default SOAP Message Factory response error

I am writing both the server and the client. The server builds the XML using JAXB marshalling and piping back to the client in the HTTP socket. From the client the request is built using the message factory and sent over the connection factory instantiation. When the response is received the SAAJ API indicates the response was bad and equals null. The client is a applet.

Error Message
Java Code:
Jun 29, 2008 5:01:49 PM com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
SEVERE: SAAJ0008: Bad Response; null
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (-1null

Client Code
Java Code:
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
if(connection == null)
	connection = soapConnectionFactory.createConnection();
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPHeader header = message.getSOAPHeader();
SOAPBody body = message.getSOAPBody();
header.detachNode();
QName bodymain = new QName("icb_xml");
SOAPBodyElement mainbodyElement =  body.addBodyElement(bodymain);
...
...
...
 URL endpoint = new URL(serverurl);
System.out.println("b");
SOAPMessage response = connection.call(message, endpoint);
Comm_log
Java Code:
[Client Request]>POST / HTTP/1.1
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type: text/xml; charset=utf-8
Content-Length: 242
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java(tm) 2 SDK, Standard Edition v1.6.0_05 Java/1.6.0_05
Host: sjdpprojectserver.hopto.org
Connection: keep-alive

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><icb_xml><login><username>jaco</username><password>12345</password><language>English</language></login></icb_xml></SOAP-ENV:Body></SOAP-ENV:Envelope>

[Server Response]><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header/><env:Body><icb_xml><loginResponse><err_code>0</err_code><user_id>101</user_id></loginResponse></icb_xml></env:Body></env:Envelope>
In your opinion is this a server or client related problem or should I look for an alternative function rather than the SOAP message factory and connection factory?

Regards,
Buglish

Last edited by Buglish; 12-10-2008 at 09:20 AM.
  #2 (permalink)  
Old 29-06-2008, 03:45 PM
Junior Member
 
Join Date: Jun 2008
Location: Pretoria, South Africa
Posts: 4
Buglish is on a distinguished road
Send a message via MSN to Buglish Send a message via Yahoo to Buglish Send a message via Skype™ to Buglish
Default Re: SOAP Message Factory response error

After I had placed the post I noticed my response SOAP message format is not the same is the client. I used in both instences the MessageFactory.

On the server side how do I detect the SOAP version?

I had change the instantiation from
Java Code:
messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
to
Java Code:
 messageFactory = MessageFactory.newInstance();
on the server.

Java Code:
[Client Request]>POST / HTTP/1.1
Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type: text/xml; charset=utf-8
Content-Length: 241
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java(tm) 2 SDK, Standard Edition v1.6.0_05 Java/1.6.0_05
Host: sjdpprojectserver.hopto.org
Connection: keep-alive

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><icb_xml><login><username>rsdth</username><password>sth</password><language>English</language></login></icb_xml></SOAP-ENV:Body></SOAP-ENV:Envelope>

[Server Response]><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><icb_xml><loginResponse><err_code>102</err_code><err_data>Login Failed. Incorrect username or password.</err_data></loginResponse></icb_xml></SOAP-ENV:Body></SOAP-ENV:Envelope>
Unfortunatly this did not resolve the problem as I still receive the above error message

Last edited by Buglish; 12-10-2008 at 09:09 AM.
  #3 (permalink)  
Old 12-10-2008, 09:14 AM
Junior Member
 
Join Date: Jun 2008
Location: Pretoria, South Africa
Posts: 4
Buglish is on a distinguished road
Send a message via MSN to Buglish Send a message via Yahoo to Buglish Send a message via Skype™ to Buglish
Default Re: SOAP Message Factory response error

Hi,

To solve this problem; I used the SOAPMEssageFactory to only create the SOAP packet and HTTPConnection for the transmission protocol. It's a normal socket push which is allot simpler and old school. This did not give my any environment errors.

Java Code:
public String sendSoapLoginMessage(String usernameintput, String passwordintput) throws Exception
    {       
        SOAPFactory soapFactory = SOAPFactory.newInstance(); 
        MessageFactory mf = MessageFactory.newInstance();
        SOAPMessage message = mf.createMessage();
        SOAPBody body = message.getSOAPBody();
        // You can detach the SOAP header in this example
        // msg.getSOAPHeader().detachNode();
        
        
        Name bodyName = soapFactory.createName("icb_xml" , "sjp", serverurl);
         
        SOAPElement xmlElement = body.addBodyElement(bodyName);


        Name loginName = soapFactory.createName("login");
        SOAPElement loginElement = xmlElement.addChildElement(loginName);

        SOAPElement child = soapFactory.createElement("username");
        child.addTextNode(usernameintput);

        loginElement.addChildElement(child);

        child = soapFactory.createElement("password");
        child.addTextNode(passwordintput);


        loginElement.addChildElement(child);

        child = soapFactory.createElement("language");
        child.addTextNode(icb.language);
        
        loginElement.addChildElement(child);

        message.saveChanges();

        // Send the message
        System.out.println("Send the SOAP message\n");
        
        
        String server = serverurl;
        String response = "";
        
        try 
        {
            if(out==null)
            {
                if(uc == null)
                {    
                    u = new URL(DEFAULT_SERVER);
                    uc = u.openConnection();
                }
                
                if(urlconnection == null)
                {    
                    urlconnection = (HttpURLConnection) uc;
                    urlconnection.setDoOutput(true);
                    urlconnection.setDoInput(true);
                    urlconnection.setRequestMethod("POST");
                    urlconnection.setRequestProperty("SOAPAction", SOAP_ACTION);
                }
                out = urlconnection.getOutputStream();
            }
            
            if(wout == null)
                wout = new OutputStreamWriter(out);

            String soapmessage = printMessage(message);
            wout.write(soapmessage); 

            wout.flush();
            //wout.close();
            System.out.println(2);
            if(is == null)
                is = urlconnection.getInputStream();
            response = readServerResponseMessage(is);
            //is.close();
            int sizemore = "</loginResponse>".length();
            response = response.substring(response.indexOf("<loginResponse>"),response.indexOf("</loginResponse>")+sizemore);
            System.out.println("[SERVER RESPONSE]"+response);
        }
        catch (IOException e) 
        {
            System.err.println(e); 
        }
        catch(Exception eb)
        {
            System.err.println(eb); 
        }        
              
        

       return response;
    }
    
public void closeConnections()
{
		try
		{
				wout.close();
				is.close();
		}
		catch(Exception e)
		{
				e.printStackTrace();
		}        
}
    
public String readServerResponseMessage(InputStream is)
{
	BufferedReader br = new BufferedReader(new InputStreamReader(is)); 
	char[] readChars = new char[65000];
	String response = "";
	try
	{   
			while (br.read(readChars) != -1)
			{           
					response = new String(readChars);
				 break;

			}

	}
	catch (IOException e)
	{   
					e.printStackTrace();
	}
	catch(Exception e)
	{
					e.printStackTrace();
	}

	return response;
}
Regards,
Buglish
  #4 (permalink)  
Old 06-11-2008, 06:42 PM
JavaPF's Avatar
Java Programmer
 
Join Date: May 2008
Location: Deep inside the Eclipse IDE
Posts: 172
JavaPF will become famous soon enoughJavaPF will become famous soon enough
Default Re: SOAP Message Factory response error

Thank you for posting your solution Buglish.

This seems to be a very popular thread so no doubt it will help others.
  #5 (permalink)  
Old 09-11-2008, 02:36 PM
JavaPF's Avatar
Java Programmer
 
Join Date: May 2008
Location: Deep inside the Eclipse IDE
Posts: 172
JavaPF will become famous soon enoughJavaPF will become famous soon enough
Default Re: SOAP Message Factory response error

For some reason this thread is getting a lot of spam messages posted in it that I keep having to remove.

I am closing this thread to stop any further messages.
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Custom Search
100 most searched terms
Search Cloud
"bad endpoint type" com.sun.xml.internal.messaging.saaj.soapexceptionimpl com.sun.xml.internal.messaging.saaj.soapexceptionimpl: bad endpoint type com.sun.xml.internal.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception com.sun.xml.internal.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: message send failed com.sun.xml.internal.messaging.saaj.soapexceptionimpl: message send failed com.sun.xml.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception com.sun.xml.messaging.saaj.soapexceptionimpl: java.security.privilegedactionexception: com.sun.xml.messaging.saaj.soapexceptionimpl: message send failed convert arraylist to map date_format_now eclipse shortcut keys ejb3 quartz java convert double to binary java forum java forums java jtextarea bold java jtextarea color java jtextarea font java jtextarea font size java programmer forum java programmers forum java programming forum java programming forums java read last line java read last line of file java sendkeys java.security.privilegedactionexception java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: bad response java.security.privilegedactionexception: com.sun.xml.internal.messaging.saaj.soapexceptionimpl: message send failed java.security.privilegedactionexception: com.sun.xml.messaging.saaj.soapexceptionimpl: message send failed javapf javaprogrammingforums jtextarea bold jtextarea font jtextarea font color jtextarea font size programing forums programming forums reset jcombobox saaj0008 saaj0008: bad response; bad request saaj0008: bad response; not found severe: saaj0008 severe: saaj0008: bad response; bad request severe: saaj0008: bad response; not found soap java.security.privilegedactionexception soapexceptionimpl: bad endpoint type textpad java

All times are GMT. The time now is 12:33 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.