A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Web Services
Author
SOAPMessage: SAXParseException
Raminder Singh
Ranch Hand
Joined: Mar 01, 2002
Posts: 72
posted
Aug 03, 2006 03:41:00
0
Hi,
I'm calling a webservice with following client and getting a exception:-
package com.client;
import
java.io.ByteArrayInputStream
;
import
java.util.Vector
;
import
javax.xml.soap.MessageFactory
;
import
javax.xml.soap.MimeHeaders
;
import
javax.xml.soap.SOAPConnection
;
import
javax.xml.soap.SOAPConnectionFactory
;
import
javax.xml.soap.SOAPEnvelope
;
import
javax.xml.soap.SOAPMessage
;
import
javax.xml.soap.SOAPPart
;
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class RetrievePNRsByCardClient01
{
public static void main(
String
[] args)
{
try{
String endpoint = "http://localhost:8080/axis/services/OSRetrievePNRsByCard";
Service service = new Service();
Call call = (Call)service.createCall();
String xmlString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n" +
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
" <soapenv:Body>\n" +
" <ns1:retrievePNRsByCard soap-env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\n" + " xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope\">\n" +
" xmlns:ns1=\"urn
s:retrievePNRsByCard\">\n" +
" <input xsi:type=\"ns1:RetrievePNRsByCardIn\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
" <creditCardNum xsi:type=\"xsd:string\">5201000100020003</creditCardNum>\n"+
" <dptrAirportCode xsi:type=\"xsd:string\">DEL</dptrAirportCode>\n"+
" <expirationDate xsi:type=\"xsd:string\">1109</expirationDate>\n"+
" </ns1:retrievePNRsByCard>\n"+
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
MessageFactory
mf = MessageFactory.newInstance();
SOAPMessage
smsg =
mf.createMessage(new
MimeHeaders
(), new
ByteArrayInputStream
(xmlString.getBytes()));
SOAPPart
sp = smsg.getSOAPPart();
SOAPEnvelope
se = (
SOAPEnvelope
)sp.getEnvelope();
SOAPConnection
conn = SOAPConnectionFactory.newInstance().createConnection();
SOAPMessage
response = conn.call(smsg, endpoint);
System.out.println("response: " + response);
MessageContext
mc = call.getMessageContext();
Vector bodyVec = mc.getResponseMessage().getSOAPEnvelope().getBodyElements();
System.out.println("Body Elements: " + bodyVec);
}catch(Exception ex)
{
System.out.println(" Exception is: " + ex.getMessage());
}
}
}
Exception is:
-------
Exception is:
org.xml.sax.SAXParseException
: The prefix "ns1" for element "ns1:retrievePNRsByCard" is not bound.
Can you let me know, how to solve it?
wise owen
Ranch Hand
Joined: Feb 02, 2006
Posts: 2023
posted
Aug 03, 2006 06:09:00
0
<ns1:retrievePNRsByCard soap-env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\n" + " xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope\">\n" + " xmlns:ns1=\"urn s:retrievePNRsByCard\">\n" +
Check this line, why you have ">".
xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope\">\n"
I agree. Here's the link:
http://aspose.com/file-tools
subject: SOAPMessage: SAXParseException
Similar Threads
problem with String [] in axis 1.3 and .net client
WSAD 5.1.1 SOAP RPC return type of Object[]
Have a question about accessing the SOAP response via VBA client.
AXIS XML calling .Net Web Service
Basic SOAP Header Question
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter