本文整理汇总了Java中org.apache.axis.MessageContext.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setProperty方法的具体用法?Java MessageContext.setProperty怎么用?Java MessageContext.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
public static String serialize(Object obj) throws IOException {
TypeDesc desc = TypeDesc.getTypeDescForClass(obj.getClass());
BeanSerializer serializer = new BeanSerializer(obj.getClass(), desc.getXmlType(), desc);
MessageContext mctx = new MessageContext(null);
mctx.setProperty(AxisEngine.PROP_ENABLE_NAMESPACE_PREFIX_OPTIMIZATION, true);
mctx.setProperty(AxisEngine.PROP_SEND_XSI, true);
mctx.setTypeMappingRegistry(new TypeMappingRegistryImpl());
StringWriter writer = new StringWriter();
SerializationContext ctx = new SerializationContext(writer, mctx);
ctx.setPretty(false);
ctx.setSendDecl(true);
ctx.setDoMultiRefs(false);
serializer.serialize(new QName("keha"), new AttributesImpl(), obj, ctx);
return writer.getBuffer().toString();
}
示例2: processMessage
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
public void processMessage(MessageContext msgContext, SOAPEnvelope reqEnv, SOAPEnvelope resEnv, Object obj) throws Exception {
RPCElement body = getBody(reqEnv, msgContext);
OperationDesc operation = getOperationDesc(msgContext, body);
AxisRpcInterceptor interceptor = new AxisRpcInterceptor(operation, msgContext);
SOAPMessage message = msgContext.getMessage();
try {
message.getSOAPPart().getEnvelope();
msgContext.setProperty(org.apache.axis.SOAPPart.ALLOW_FORM_OPTIMIZATION, Boolean.FALSE);
RpcContainer container = (RpcContainer) ejbDeployment.getContainer();
Object[] arguments = {msgContext, interceptor};
Class callInterface = ejbDeployment.getServiceEndpointInterface();
Object result = container.invoke(ejbDeployment.getDeploymentID(), InterfaceType.SERVICE_ENDPOINT, callInterface, operation.getMethod(), arguments, null);
interceptor.createResult(result);
} catch (ApplicationException e) {
interceptor.createExceptionResult(e.getCause());
} catch (Throwable throwable) {
throw new AxisFault("Web Service EJB Invocation failed: method " + operation.getMethod(), throwable);
}
}
示例3: testInvokeReturnsValidXml
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* Tests that a valid XML response results in a successful invocation of the handler that produces
* a valid SOAP envelope.
*/
@Test
public void testInvokeReturnsValidXml() throws IOException {
// Unlike the failure tests below, create the MessageContext here with an actual AxisClient,
// not a mock AxisEngine. Otherwise, the call to getSOAPEnvelope below will fail.
MessageContext messageContext = new MessageContext(new AxisClient());
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
SoapResponseXmlProvider.getTestSoapResponse(API_VERSION);
mockHttpServer.setMockResponse(
new MockResponse(SoapResponseXmlProvider.getTestSoapResponse(API_VERSION)));
httpHandler.invoke(messageContext);
assertNotNull(
"SOAP envelope of response is null", messageContext.getResponseMessage().getSOAPEnvelope());
}
示例4: testInvokeReturnsInvalidXml
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/** Tests that a poorly formed XML response will result in an AxisFault. */
@Test
public void testInvokeReturnsInvalidXml() throws AxisFault {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
messageContext.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
mockHttpServer.setMockResponse(
new MockResponse(
"<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
+ "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
+ "foo..."));
httpHandler.invoke(messageContext);
// Expect parsing to fail. Tear down will verify the stream was closed.
thrown.expect(AxisFault.class);
messageContext.getResponseMessage().getSOAPEnvelope();
}
示例5: setupMessageContextImpl
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* Set up any transport-specific derived properties in the message context.
* @param context the context to set up
* @param message the client service instance
* @param engine the engine containing the registries
*/
public void setupMessageContextImpl(MessageContext mc,
Call call,
AxisEngine engine)
{
try {
String urlString = mc.getStrProp(MessageContext.TRANS_URL);
if (urlString != null) {
URL url = new URL(urlString);
host = url.getHost();
port = new Integer(url.getPort()).toString();
}
} catch (java.net.MalformedURLException e) {
// Do nothing here?
}
if (host != null) mc.setProperty(HOST, host);
if (port != null) mc.setProperty(PORT, port);
log.debug( "Port = " + mc.getStrProp(PORT));
log.debug( "Host = " + mc.getStrProp(HOST));
// kind of ugly... fake up a "http://host:port/" url to send down the chain
// ROBJ TODO: clean this up so we use TCP transport properties all the way down
// use serviceclient properties if any, otherwise use ours
/*
String url = "http://"+serv.get(HOST)+":"+serv.get(PORT);
log.debug( "TCPTransport set URL to '" + url + "'");
mc.setProperty(MessageContext.TRANS_URL, url);
*/
}
示例6: invoke
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
public void invoke(MessageContext msgContext) throws AxisFault {
try {
msgContext.setProperty(AxisEngine.PROP_DISABLE_PRETTY_XML, true);
SOAPMessage msg = msgContext.getCurrentMessage();
Document doc = ((org.apache.axis.message.SOAPEnvelope)msg.getSOAPPart().getEnvelope()).getAsDocument();
SOAPMessage secMsg = this.createUserNameToken(doc);
((SOAPPart)msgContext.getRequestMessage().getSOAPPart()).setCurrentMessage(secMsg.getSOAPPart().getEnvelope(), SOAPPart.FORM_SOAPENVELOPE);
} catch (Exception ex) {
throw new AxisFault("(Invoke) Error en la cridada a aFirma " + ex.getMessage(), ex);
}
}
示例7: invoke
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
public void invoke(MessageContext context)
throws AxisFault
{
String sessionId = AuthenticationUtils.getAuthenticationDetails().getSessionId();
if (sessionId != null)
{
context.setProperty(HTTPConstants.HEADER_COOKIE, "JSESSIONID=" + sessionId);
}
}
示例8: makeFault
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* Create an connection problem AxisFault from an Exception
*
* @param e Exception
* @param deadline Not used
* @param remoteURL Remote URL
* @param msgContext MessageContext object
* @return AxisFault
*/
private AxisFault makeFault(final Exception e,
final long deadline,
final String remoteURL,
final MessageContext msgContext)
{
msgContext.setProperty(ERROR_IN_HTTPSENDER, Boolean.TRUE);
// Clear the expected server certificate set from this thread
LavercaSSLTrustManager.getInstance().setExpectedServerCerts(null);
return this.makeFault(msgContext, e, remoteURL);
}
示例9: createMessageContext
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
protected MessageContext createMessageContext(InputStream configStream) {
EngineConfiguration engineConfig = new FileProvider(configStream);
AxisEngine engine = new AxisServer(engineConfig);
MessageContext context = new MessageContext(engine);
context.setEncodingStyle("");
context.setProperty(AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
// the following two properties prevent xsd types from appearing in
// every single element in the serialized XML
context.setProperty(AxisEngine.PROP_EMIT_ALL_TYPES, Boolean.FALSE);
context.setProperty(AxisEngine.PROP_SEND_XSI, Boolean.FALSE);
return context;
}
示例10: toObject
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
public static <T> T toObject(InputSource source, Class<T> javaClass, InputStream wsdd) throws SAXException {
// create a message context for the wsdd
EngineConfiguration engineConfig = new FileProvider(wsdd);
AxisClient axisClient = new AxisClient(engineConfig);
MessageContext messageContext = new MessageContext(axisClient);
messageContext.setEncodingStyle("");
messageContext.setProperty(AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
ConfigurableObjectDeserializationContext desContext = new ConfigurableObjectDeserializationContext(
messageContext, source, javaClass);
return javaClass.cast(desContext.getValue());
}
示例11: testInvokeReturnsNonXmlResponse
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* Tests that a failed, non-XML response results in an AxisFault containing the HTTP status and
* message.
*/
@Test
public void testInvokeReturnsNonXmlResponse() throws AxisFault {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
messageContext.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
MockResponse mockResponse = new MockResponse("Something went wrong", 500);
mockResponse.setContentType("text/html");
mockHttpServer.setMockResponse(mockResponse);
// Expect an AxisFault based on the status code and content type.
thrown.expect(AxisFault.class);
httpHandler.invoke(messageContext);
}
示例12: testInvokeWithoutContentType
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/** Tests that a request with null content type will fail as expected. */
@Test
public void testInvokeWithoutContentType() throws AxisFault {
MessageContext messageContext = new MessageContext(axisEngine);
messageContext.setRequestMessage(requestMessage);
messageContext.setProperty(MessageContext.TRANS_URL, mockHttpServer.getServerUrl());
messageContext.setProperty(HTTPConstants.MC_GZIP_REQUEST, true);
MockResponse mockResponse = new MockResponse("Something went wrong", 500);
mockResponse.setContentType(null);
mockHttpServer.setMockResponse(mockResponse);
// Expect an AxisFault based on the status code and content type.
thrown.expect(AxisFault.class);
httpHandler.invoke(messageContext);
}
示例13: handleCookie
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* little helper function for cookies. fills up the message context with
* a string or an array of strings (if there are more than one Set-Cookie)
*
* @param cookieName
* @param setCookieName
* @param cookie
* @param msgContext
*/
public void handleCookie(String cookieName, String setCookieName,
String cookie, MessageContext msgContext) {
cookie = cleanupCookie(cookie);
int keyIndex = cookie.indexOf("=");
String key = (keyIndex != -1) ? cookie.substring(0, keyIndex) : cookie;
ArrayList cookies = new ArrayList();
Object oldCookies = msgContext.getProperty(cookieName);
boolean alreadyExist = false;
if(oldCookies != null) {
if(oldCookies instanceof String[]) {
String[] oldCookiesArray = (String[])oldCookies;
for(int i = 0; i < oldCookiesArray.length; i++) {
String anOldCookie = oldCookiesArray[i];
if (key != null && anOldCookie.indexOf(key) == 0) { // same cookie key
anOldCookie = cookie; // update to new one
alreadyExist = true;
}
cookies.add(anOldCookie);
}
} else {
String oldCookie = (String)oldCookies;
if (key != null && oldCookie.indexOf(key) == 0) { // same cookie key
oldCookie = cookie; // update to new one
alreadyExist = true;
}
cookies.add(oldCookie);
}
}
if (!alreadyExist) {
cookies.add(cookie);
}
if(cookies.size()==1) {
msgContext.setProperty(cookieName, cookies.get(0));
} else if (cookies.size() > 1) {
msgContext.setProperty(cookieName, cookies.toArray(new String[cookies.size()]));
}
}
示例14: handleCookie
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* little helper function for cookies. fills up the message context with a
* string or an array of strings (if there are more than one Set-Cookie)
*
* @param cookieName
* @param setCookieName
* @param cookie
* @param msgContext
*/
public void handleCookie(String cookieName, String cookie,
MessageContext msgContext) {
cookie = cleanupCookie(cookie);
int keyIndex = cookie.indexOf("=");
String key = (keyIndex != -1) ? cookie.substring(0, keyIndex) : cookie;
ArrayList cookies = new ArrayList();
Object oldCookies = msgContext.getProperty(cookieName);
boolean alreadyExist = false;
if(oldCookies != null) {
if(oldCookies instanceof String[]) {
String[] oldCookiesArray = (String[])oldCookies;
for(int i = 0; i < oldCookiesArray.length; i++) {
String anOldCookie = oldCookiesArray[i];
if (key != null && anOldCookie.indexOf(key) == 0) { // same
// cookie
// key
anOldCookie = cookie; // update to new one
alreadyExist = true;
}
cookies.add(anOldCookie);
}
} else {
String oldCookie = (String)oldCookies;
if (key != null && oldCookie.indexOf(key) == 0) { // same
// cookie
// key
oldCookie = cookie; // update to new one
alreadyExist = true;
}
cookies.add(oldCookie);
}
}
if (!alreadyExist) {
cookies.add(cookie);
}
if(cookies.size()==1) {
msgContext.setProperty(cookieName, cookies.get(0));
} else if (cookies.size() > 1) {
msgContext.setProperty(cookieName, cookies.toArray(new String[cookies.size()]));
}
}
示例15: createMessageContext
import org.apache.axis.MessageContext; //导入方法依赖的package包/类
/**
* Place the Request message in the MessagContext object - notice
* that we just leave it as a 'ServletRequest' object and let the
* Message processing routine convert it - we don't do it since we
* don't know how it's going to be used - perhaps it might not
* even need to be parsed.
* @return a message context
*/
private MessageContext createMessageContext(AxisEngine engine, HttpServletRequest req, HttpServletResponse res, Component component) {
MessageContext msgContext = new MessageContext(engine);
String requestPath = getRequestPath(req);
if (isDebug) {
log.debug("MessageContext:" + msgContext);
log.debug("HEADER_CONTENT_TYPE:" +
req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE));
log.debug("HEADER_CONTENT_LOCATION:" +
req.getHeader(HTTPConstants.HEADER_CONTENT_LOCATION));
log.debug("Constants.MC_HOME_DIR:" + String.valueOf(homeDir));
log.debug("Constants.MC_RELATIVE_PATH:" + requestPath);
log.debug("HTTPConstants.MC_HTTP_SERVLETLOCATION:" +String.valueOf(webInfPath));
log.debug("HTTPConstants.MC_HTTP_SERVLETPATHINFO:" +req.getPathInfo());
log.debug("HTTPConstants.HEADER_AUTHORIZATION:" +req.getHeader(HTTPConstants.HEADER_AUTHORIZATION));
log.debug("Constants.MC_REMOTE_ADDR:" + req.getRemoteAddr());
log.debug("configPath:" + String.valueOf(webInfPath));
}
/* Set the Transport */
/*********************/
msgContext.setTransportName("http");
/* Save some HTTP specific info in the bag in case someone needs it */
/********************************************************************/
//msgContext.setProperty(Constants.MC_JWS_CLASSDIR, jwsClassDir);
msgContext.setProperty(Constants.MC_HOME_DIR, homeDir);
msgContext.setProperty(Constants.MC_RELATIVE_PATH, requestPath);
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLET, this);
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req);
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, res);
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETLOCATION,webInfPath);
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO,req.getPathInfo());
msgContext.setProperty(HTTPConstants.HEADER_AUTHORIZATION,req.getHeader(HTTPConstants.HEADER_AUTHORIZATION));
msgContext.setProperty(lucee.runtime.net.rpc.server.Constants.COMPONENT, component);
msgContext.setProperty(Constants.MC_REMOTE_ADDR, req.getRemoteAddr());
// Set up a javax.xml.rpc.server.ServletEndpointContext
ServletEndpointContextImpl sec = new ServletEndpointContextImpl();
msgContext.setProperty(Constants.MC_SERVLET_ENDPOINT_CONTEXT, sec);
/* Save the real path */
/**********************/
String relpath = context.getRealPath(requestPath);
if (relpath != null) {
msgContext.setProperty(Constants.MC_REALPATH, relpath);
}
msgContext.setProperty(Constants.MC_CONFIGPATH, webInfPath);
return msgContext;
}