1 57 58 package org.apache.soap.server; 59 60 import java.io.*; 61 import java.util.*; 62 import java.lang.reflect.*; 63 import javax.activation.*; 64 import javax.mail.BodyPart ; 65 import javax.mail.MessagingException ; 66 import javax.mail.internet.*; 67 import javax.servlet.*; 68 import javax.xml.parsers.*; 69 import org.w3c.dom.* ; 70 import org.apache.soap.*; 71 import org.apache.soap.rpc.*; 72 import org.apache.soap.server.http.*; 73 import org.apache.soap.util.*; 74 import org.apache.soap.util.xml.*; 75 import org.apache.soap.util.mime.*; 76 import org.apache.soap.transport.EnvelopeEditor; 77 import org.apache.soap.transport.TransportMessage; 78 79 85 public class ServerUtils { 86 96 public static Envelope readEnvelopeFromInputStream (DocumentBuilder xdb, 97 InputStream is, 98 int contentLength, 99 String contentType, 100 EnvelopeEditor editor, 101 SOAPContext ctx) 102 throws SOAPException, IOException, 103 IllegalArgumentException , MessagingException { 104 TransportMessage reqMsg = new TransportMessage(is, contentLength, 106 contentType, ctx, 107 null); 108 reqMsg.read(); 110 MimeBodyPart rootPart = ctx.getRootPart(); 113 if (!rootPart.isMimeType(Constants.HEADERVAL_CONTENT_TYPE)) 114 throw new SOAPException(Constants.FAULT_CODE_PROTOCOL, 115 "Unsupported content type \"" + 116 rootPart.getContentType() + "\", must be: \"" + 117 Constants.HEADERVAL_CONTENT_TYPE + "\"."); 118 reqMsg.editIncoming(editor); 120 return reqMsg.unmarshall(xdb); 122 } 123 124 public static Provider loadProvider(DeploymentDescriptor dd, 125 SOAPContext ctxt) 126 throws SOAPException { 127 String className ; 128 Class c ; 129 Object newObj ; 130 131 className = dd.getServiceClass(); 132 if (className == null) 133 return null; 134 135 if (className.equals("java")) 136 className = "org.apache.soap.providers.RPCJavaProvider"; 137 else if (className.equals("script")) 138 className = "org.apache.soap.providers.RPCJavaProvider"; 139 140 try { 141 c = ctxt.loadClass( className ); 142 newObj = c.newInstance(); 143 } catch(Exception exp) { 144 throw new SOAPException(Constants.FAULT_CODE_SERVER, 145 "Can't load provider '" + className + "'", 146 exp); 147 } 148 149 if (!(newObj instanceof Provider)) 150 throw new SOAPException(Constants.FAULT_CODE_SERVER, 151 "'" + className + "' isn't a provider"); 152 153 return (Provider)newObj; 154 } 155 } 156 | Popular Tags |