Link to home
Start Free TrialLog in
Avatar of ok_lilya
ok_lilya

asked on

Soap call exception

Hi,

I'm trying to create a simple client to make a soap call to Websphere 5 server.
Here is my code:

package soapcall;

import javax.xml.soap.*;
import java.util.*;
import java.net.URL;

public class SoapCall {
      
  public static void main(String[] args)  {
    try {
      SOAPConnectionFactory scFactory =
          SOAPConnectionFactory.newInstance();
      SOAPConnection con = scFactory.createConnection();

      MessageFactory factory =
          MessageFactory.newInstance();
      SOAPMessage message = factory.createMessage();
 
      SOAPPart soapPart = message.getSOAPPart();
      SOAPEnvelope envelope = soapPart.getEnvelope();
      SOAPHeader header = envelope.getHeader();
      SOAPBody body = envelope.getBody();
      header.detachNode();
 
      Name bodyName = envelope.createName(
              "enFilterUndeliverableEmail", "m",
              "http://localhost:9080/3m00Undel/undeliverable/EmailParser");
      SOAPBodyElement gltp =
              body.addBodyElement(bodyName);
 
      Name name = envelope.createName("symbol");
      SOAPElement symbol = gltp.addChildElement(name);
      symbol.addTextNode("SUNW");
 
      URL endpoint = new URL
                ("http://localhost:9080/3m00Undel/undeliverable/EmailParser");
      SOAPMessage response = con.call(message, endpoint);
 
      con.close();
 
      SOAPPart sp = response.getSOAPPart();
      SOAPEnvelope se = sp.getEnvelope();
      SOAPBody sb = se.getBody();
 
      //Iterator it = sb.getChildElements(bodyName);
      //SOAPBodyElement bodyElement =
        //      (SOAPBodyElement)it.next();
      //String lastPrice = bodyElement.getValue();
 
      System.out.print("The last price for SUNW is ");
      //System.out.println(lastPrice);
 
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}

It crashes on 3rd line: SOAPConnection con = scFactory.createConnection();
And this is the error:
java.lang.ExceptionInInitializerError: java.lang.SecurityException: Prohibited package name: java.util.logging
      at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:133)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:319)
      at java.net.URLClassLoader.access$400(URLClassLoader.java:92)
      at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:677)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:238)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:514)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:441)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:446)
      at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnection.<clinit>(HttpSOAPConnection.java:37)
      at com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory.createConnection(HttpSOAPConnectionFactory.java:25)
      at soapcall.SoapCall.main(SoapCall.java:22)
Exception in thread "main"

Please help!

Thanks,

Lily



Avatar of Belthazor
Belthazor

Avatar of ok_lilya

ASKER

Hi,

The solution that they are describing is "This is a security thing. You just arent allowed to put classes in the java.* package. This is to prevent "fake" classes."
However, I'm not putting any classes in the java.*package. All I'm trying to do is create a soap call. I read instruction on some of the websites that listed all the jars that are needed and I have all of them:
commons-logging.jar
mail.jar
activation.jar
xercesImpl.jar
dom.jar
sax.jar
xalan.jar
rt.jar
saaj-api.jar
saaj-impl.jar

All I'm trying to do is to run that program to make a soap call. But it crashes at the second line. (The program that I'm using is mentioned in the previous message) I'm really lost as to what I should do about this problem.

Thanks,

Lily
ASKER CERTIFIED SOLUTION
Avatar of zeus_akkali
zeus_akkali

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial