You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Jyothi K <jy...@india.softalia.com> on 2001/08/07 08:47:57 UTC
Problem when sending the message from Apache client to non apache
server
Hi,
I have my soap C++ server and apache java client. In my server i
have the method of adding two numbers. From client i send the xml with two
numbers. the server recieves the envelope processes it and sends back the
response with the sum as return value. Now my problem is when i just send
the xml(reading the xml file and writing to io and again reading the
response of server from io), the client and server are working fine. But
when i use the same xml and parse it and send then i am getting a null
pointer exception.
Here is the client code that i am using.
public class SendMessage {
public static void main (String[] args) throws Exception {
if (args.length != 2) {
System.err.println ("Usage: java " + SendMessage.class.getName () +
" SOAP-router-URL envelope-file");
System.exit (1);
}
// get the envelope to send
FileReader fr = new FileReader (args[1]);
DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
Document doc = xdb.parse (new InputSource (fr));
if (doc == null) {
throw new SOAPException (Constants.FAULT_CODE_CLIENT, "parsing
error");
}
Envelope msgEnv = Envelope.unmarshall (doc.getDocumentElement ());
Message msg = new Message ();
try
{
msg.send (new URL (args[0]), "", msgEnv); //getting exception here
as nullpointer exception. Please let me know why?
}
catch(Exception e)
{
System.out.println("into the exception");
}
}
}
Here is the message envelope that the client is sending to the server. And
the envelope is sent correctly.
POST /soap/Calculation
HTTP/1.0 Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: 666
SOAPAction: ""
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Body>
<add SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<a xsi:type="xsd:int"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">5</a>
<b xsi:type="xsd:int"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">6</b>
</add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Here is the message envelope sent by the server after recieving the client
message.
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<addResponse
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" >
<returnValue xsi:type="xsd:int">11</returnValue>
</addResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am not knowing why i am getting null pointer exception when when i say
msg.send. Please help me. Is there any problem with the Apache's way of
parsing the envelope? But it is sending the envelope correctly, then why am
i getting the null pointer exception?
Thanks,
Jyothi