8 Replies Latest reply: Sep 19, 2008 8:50 AM by 807589 RSS

    Getting Exception while getting SOAP connection

    807589
      When I execute the below codes
      import javax.xml.soap.*;
      import javax.xml.*;
      import java.io.*;
      import java.net.*;
      
      public class Main {
      
      
      public static void main(String[] args) {
      // TODO code application logic here
      String uddiServer = "http://uddi.ibm.com/beta/inquiryapi";
      
      try {
      SOAPConnectionFactory scf =
      SOAPConnectionFactory.newInstance();
      SOAPConnection connection = scf.createConnection();
      
      MessageFactory msgFactory = MessageFactory.newInstance();
      SOAPMessage msg = msgFactory.createMessage();
      SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();
      SOAPBody body = envelope.getBody();
      
      body.addChildElement(
      envelope.createName("find_service", "",
      "urn:uddi-org:api_v2"))
      .addAttribute(envelope.createName("generic"), "2.0")
      .addAttribute(envelope.createName("maxRows"), "100")
      .addChildElement(envelope.createName("name"))
      .addTextNode("Federal Government Service");
      
      URL endpoint = new URL(uddiServer);
      
      msg.saveChanges();
      System.out.println("\n---- Request Message ----\n");
      msg.writeTo(System.out);
      SOAPMessage reply = connection.call(msg, endpoint);
      System.out.println("\n\nReceived reply from: "+endpoint);
      System.out.println("\n---- Reply Message ----\n");
      reply.writeTo(System.out);
      System.out.println();
      
      connection.close();
      
      } catch (Exception ex) {
      ex.printStackTrace();
      }
      }
      }
      When executing the above codes I am getting following exceptions
      - java.io.IOException:
      AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
      faultSubcode: 
      faultString: java.lang.ClassCastException: org.apache.axis.message.MessageElement
      faultActor: 
      faultNode: 
      faultDetail: 
      {http://xml.apache.org/axis/}stackTrace: java.lang.ClassCastException: org.apache.axis.message.MessageElement
      at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:173)
      at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:509)
      at org.apache.axis.message.MessageElement.output(MessageElement.java:783)
      at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:270)
      at org.apache.axis.Message.writeTo(Message.java:440)
      at soap_call.Main.main(Main.java:41)
      
      
      java.lang.ClassCastException: org.apache.axis.message.MessageElement
      at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
      at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:272)
      at org.apache.axis.Message.writeTo(Message.java:440)
      at soap_call.Main.main(Main.java:41)
      Caused by: java.lang.ClassCastException: org.apache.axis.message.MessageElement
      at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:173)
      at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:509)
      at org.apache.axis.message.MessageElement.output(MessageElement.java:783)
      at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:270)
      ... 2 more
      - Configuration file read-only so engine configuration changes will not be saved.
      javax.xml.soap.SOAPException: Error invoking operation: 
      java.lang.ClassCastException: org.apache.axis.message.MessageElement
      at org.apache.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:110)
      at soap_call.Main.main(Main.java:42)
      Caused by: Error invoking operation: 
      java.lang.ClassCastException: org.apache.axis.message.MessageElement
      at org.apache.axis.client.Call.invoke(Call.java:1768)
      at org.apache.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:105)
      ... 1 more
      Can any one help me solve this exception?