我试图将applet运行到.Net Web项目中,我将一个jar导入到项目中,包含我用Eclipse开发的所有applet,一切正常,直到我运行applet,当我运行它时我有这个错误,我不知道如何解决它错误是这样的:
feb 04, 2015 12:29:11 PM com.sun.xml.internal.messaging.saaj.soap.MessageImpl saveChanges
SEVERE: SAAJ0540: error al guardar un mensaje de varias partes
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.saveChanges(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(Unknown Source)
at paqSoap.Soap.enviar_y_obtener_string(Soap.java:259)
at paqConfiguracion.ConfiguracionLetra.<init>(ConfiguracionLetra.java:508)
at paqApplet.PruebaLetra.iniciarVariables(PruebaLetra.java:210)
at paqApplet.PruebaLetra.init(PruebaLetra.java:109)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.xml.internal.messaging.saaj.util.FastInfosetReflection.<clinit>(Unknown Source)
at com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer.transform(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl.output(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.getHeaderBytes(Unknown Source)
... 9 more
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "com.sun.xml.internal.fastinfoset.parser.string-interning" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at com.sun.xml.internal.fastinfoset.Decoder.<clinit>(Unknown Source)
... 17 more
我拥有这部分代码的代码就是这个:
public String enviar_y_obtener_string() throws DOMException, SOAPException {
AccessController.doPrivilegedWithCombiner(new PrivilegedAction<String>(){
public String run(){
try
{
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection connection = scf.createConnection();
//Crea el mensaje
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
/* MimeHeaders hd = message.getMimeHeaders();
String serverURI = this.soapAction+metodo;
hd.addHeader("SOAPAction", serverURI);*/
System.out.println("El mensaje al principio es:"+message);
//Crea las partes del mensaje
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
System.out.println("El servidor en enviar_y_obtener_string es:"+servidor+" y el método es:"+metodo);
//Name n = envelope.createName(metodo,"",servidor);
Name n = envelope.createName(metodo,"","http://localhost:3624/");
SOAPBodyElement soapBodyElement =body.addBodyElement(n);
for(int i=0;i<lista_nombre_parametros.size();i++)
{
//Name name2 = envelope.createName(this.lista_nombre_parametros.get(i).toString());
//SOAPElement soapElement = soapBodyElement.addChildElement(name2);
SOAPElement soapElement = soapBodyElement.addChildElement(lista_nombre_parametros.get(i).toString());
System.out.println("El nombre del parámetro es:"+lista_nombre_parametros.get(i).toString());
int tipo=Integer.valueOf(lista_tipo_parametro.get(i).toString()).intValue();
if(tipo==IdTipoCadena){
//soapElement.addTextNode("437");
soapElement.addTextNode(lista_valores_parametros.get(i).toString());
System.out.println("El valor es:"+ lista_valores_parametros.get(i).toString());
}
else
{
SOAPFactory soapFactory = SOAPFactory.newInstance();
Name nodeName = envelope.createName("nodo");
SOAPElement soapElementint=soapElement.addChildElement(nodeName);
ArrayList arraydev=(ArrayList)lista_valores_parametros.get(i);
for(int j=0;j<arraydev.size();j++)
{
Name name3 = envelope.createName("carlos");
SOAPElement soapElementhijo=soapElementint.addChildElement(name3);
soapElementhijo.addTextNode("p");
}
}
}
message.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean( true ));
message.setProperty(Call.SOAPACTION_URI_PROPERTY,url);
MimeHeaders hd = message.getMimeHeaders();
// String serverURI = this.soapAction+metodo;
String serverURI = soapAction;
System.out.println("ServerURI en enviar_y_obtener_string es:"+serverURI);
hd.addHeader("SOAPAction", "http://localhost:3624/getConfig");
//hd.addHeader("SOAPAction", serverURI);
//message.saveChanges();
url=leerPropiedades()[2];
System.out.println("La url es dentro de enviar_y_obtener_string:"+url);
//Establece la URL del destino
URL endpoint = new URL(url);
//Envía el mensaje
System.out.println("Endpoint es:"+endpoint);
String msg;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
message.writeTo(baos);
msg = baos.toString();
System.out.println("msg es:"+message);
SOAPMessage response = connection.call(message, endpoint);
System.out.println("Voy a cerrar la conexión");
//Cierra la conexión
connection.close();
//Obtiene los resultados
TransformerFactory tf = TransformerFactory.newInstance();
return response.getSOAPBody().getFirstChild().getTextContent();
}
catch (Exception ex)
{
ex.printStackTrace();
return "";
}
}
});
return response.getSOAPBody().getFirstChild().getTextContent();
}
当我在.Net中运行applet时,我也使用xercesImpl.jar和xml-apis.jar,那么这里的问题是什么?我有点失落。
非常感谢和问候
答案 0 :(得分:0)
以下是您需要采取的几个步骤:
enviar_y_obtener_string
PrivilegedAction<String>
执行
String
AccessController.doPrivileged(yourPrivilegedAction)
另外,您要考虑: