Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

SOAPMessage: SAXParseException

Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm calling a webservice with following client and getting a exception:-

package com.client;

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)
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=\"\"\n" +
" xmlns:xsd=\"\"\n" +
" xmlns:xsi=\"\">\n" +
" <soapenv:Body>\n" +
" <ns1:retrievePNRsByCard soap-env:encodingStyle=\"\"\n" + " xmlns:soap-env=\"\">\n" +
" xmlns:ns1=\"urn s:retrievePNRsByCard\">\n" +
" <input xsi:type=\"ns1:RetrievePNRsByCardIn\" xmlns:xsi=\"\">\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" +

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 =, 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?
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Check this line, why you have ">".
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic