当前位置: 首页>>代码示例>>Java>>正文


Java HTTPConstants类代码示例

本文整理汇总了Java中org.apache.axis.transport.http.HTTPConstants的典型用法代码示例。如果您正苦于以下问题:Java HTTPConstants类的具体用法?Java HTTPConstants怎么用?Java HTTPConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HTTPConstants类属于org.apache.axis.transport.http包,在下文中一共展示了HTTPConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInvokeReturnsInvalidXml

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的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();
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:21,代码来源:HttpHandlerTest.java

示例2: initPool

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
static private void initPool() {
  if (log4j.isDebugEnabled())
    log4j.debug("init");
  try {
    HttpServlet srv = (HttpServlet) MessageContext.getCurrentContext().getProperty(
        HTTPConstants.MC_HTTP_SERVLET);
    ServletContext context = srv.getServletContext();
    pool = ConnectionProviderContextListener.getPool(context);
  } catch (Exception e) {
    log4j.error("Error : initPool");
    log4j.error(e.getStackTrace());
  }
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:14,代码来源:VersionUtility.java

示例3: invoke

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
public void invoke(MessageContext context) 
    throws AxisFault 
{
    String sessionId = AuthenticationUtils.getAuthenticationDetails().getSessionId();
    if (sessionId != null)
    {
        context.setProperty(HTTPConstants.HEADER_COOKIE, "JSESSIONID=" + sessionId);
    }
}
 
开发者ID:xenit-eu,项目名称:move2alf,代码行数:10,代码来源:CookieHandler.java

示例4: getManagementService

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
public ManagementService getManagementService() throws Exception {

		if (managementService == null) {
			ManagementServiceServiceLocator rsl = new ManagementServiceServiceLocator(getEngineConfiguration());
			managementService = rsl.getrepository(new java.net.URL(getWebservicesUri()));
			((org.apache.axis.client.Stub) managementService).setUsername(getUsername());
			((org.apache.axis.client.Stub) managementService).setPassword(getPassword());
			((org.apache.axis.client.Stub) managementService).setMaintainSession(true);
			((org.apache.axis.client.Stub) managementService).setTimeout(getTimeout());

			Hashtable headers = (Hashtable) ((org.apache.axis.client.Stub) managementService)._getProperty(HTTPConstants.REQUEST_HEADERS);
			if (headers == null)
				headers = new Hashtable();
			headers.put(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED, isChuncked() ? Boolean.TRUE : Boolean.FALSE);
			((org.apache.axis.client.Stub) managementService)._setProperty(HTTPConstants.REQUEST_HEADERS, headers);

		}

		// int timeout = IReportManager.getPreferences().getInt("client_timeout", 0)
		// * 1000;
		// if (timeout !=
		// ((org.apache.axis.client.Stub)managementService).getTimeout())
		// {
		// ((org.apache.axis.client.Stub)managementService).setTimeout(timeout);
		// }
		return managementService;
	}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:28,代码来源:WSClient.java

示例5: getUserAndRoleManagementService

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * @return the userAndRoleManagementService
 */
public UserAndRoleManagement getUserAndRoleManagementService() throws Exception {

	if (userAndRoleManagementService == null) {
		UserAndRoleManagementServiceLocator rsl = new UserAndRoleManagementServiceLocator(getEngineConfiguration());
		String uriString = getWebservicesUri();
		uriString = uriString.replace("/repository", "/UserAndRoleManagementService"); //$NON-NLS-1$ //$NON-NLS-2$

		userAndRoleManagementService = rsl.getUserAndRoleManagementServicePort(new java.net.URL(uriString));
		((org.apache.axis.client.Stub) userAndRoleManagementService).setUsername(getUsername());
		((org.apache.axis.client.Stub) userAndRoleManagementService).setPassword(getPassword());
		((org.apache.axis.client.Stub) userAndRoleManagementService).setMaintainSession(true);
		((org.apache.axis.client.Stub) userAndRoleManagementService).setTimeout(getTimeout());
		Hashtable headers = (Hashtable) ((org.apache.axis.client.Stub) userAndRoleManagementService)._getProperty(HTTPConstants.REQUEST_HEADERS);
		if (headers == null)
			headers = new Hashtable();
		headers.put(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED, isChuncked() ? Boolean.TRUE : Boolean.FALSE);
		((org.apache.axis.client.Stub) userAndRoleManagementService)._setProperty(HTTPConstants.REQUEST_HEADERS, headers);
	}

	// int timeout =
	// IReportManager.getPreferences().getInt("client_timeout", 0) * 1000;
	// if (timeout !=
	// ((org.apache.axis.client.Stub)managementService).getTimeout())
	// {
	// ((org.apache.axis.client.Stub)managementService).setTimeout(timeout);
	// }
	return userAndRoleManagementService;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:32,代码来源:WSClient.java

示例6: getPermissionsManagement

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * @return the permissionsManagement
 */
public PermissionsManagement getPermissionsManagement() throws Exception {
	if (permissionsManagement == null) {
		PermissionsManagementServiceLocator rsl = new PermissionsManagementServiceLocator(getEngineConfiguration());
		String uriString = getWebservicesUri();
		uriString = uriString.replace("/repository", "/PermissionsManagementService"); //$NON-NLS-1$ //$NON-NLS-2$

		permissionsManagement = rsl.getPermissionsManagementServicePort(new java.net.URL(uriString));
		((org.apache.axis.client.Stub) permissionsManagement).setUsername(getUsername());
		((org.apache.axis.client.Stub) permissionsManagement).setPassword(getPassword());
		((org.apache.axis.client.Stub) permissionsManagement).setMaintainSession(true);
		((org.apache.axis.client.Stub) permissionsManagement).setTimeout(getTimeout());
		Hashtable headers = (Hashtable) ((org.apache.axis.client.Stub) permissionsManagement)._getProperty(HTTPConstants.REQUEST_HEADERS);
		if (headers == null)
			headers = new Hashtable();
		headers.put(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED, isChuncked() ? Boolean.TRUE : Boolean.FALSE);
		((org.apache.axis.client.Stub) permissionsManagement)._setProperty(HTTPConstants.REQUEST_HEADERS, headers);
	}

	// int timeout =
	// IReportManager.getPreferences().getInt("client_timeout", 0) * 1000;
	// if (timeout !=
	// ((org.apache.axis.client.Stub)managementService).getTimeout())
	// {
	// ((org.apache.axis.client.Stub)managementService).setTimeout(timeout);
	// }
	return permissionsManagement;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:31,代码来源:WSClient.java

示例7: getReportScheduler

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * @return the reportSchedulerService
 */
public ReportScheduler getReportScheduler() throws Exception {
	if (reportScheduler == null) {
		ReportSchedulerServiceLocator rsl = new ReportSchedulerServiceLocator(getEngineConfiguration());
		String uriString = getWebservicesUri();
		uriString = uriString.replace("/repository", "/ReportScheduler"); //$NON-NLS-1$ //$NON-NLS-2$

		reportScheduler = rsl.getReportScheduler(new java.net.URL(uriString));
		((org.apache.axis.client.Stub) reportScheduler).setUsername(getUsername());
		((org.apache.axis.client.Stub) reportScheduler).setPassword(getPassword());
		((org.apache.axis.client.Stub) reportScheduler).setMaintainSession(true);
		((org.apache.axis.client.Stub) reportScheduler).setTimeout(getTimeout());
		Hashtable headers = (Hashtable) ((org.apache.axis.client.Stub) reportScheduler)._getProperty(HTTPConstants.REQUEST_HEADERS);
		if (headers == null)
			headers = new Hashtable();
		headers.put(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED, isChuncked() ? Boolean.TRUE : Boolean.FALSE);
		((org.apache.axis.client.Stub) reportScheduler)._setProperty(HTTPConstants.REQUEST_HEADERS, headers);
	}

	// int timeout =
	// IReportManager.getPreferences().getInt("client_timeout", 0) * 1000;
	// if (timeout !=
	// ((org.apache.axis.client.Stub)managementService).getTimeout())
	// {
	// ((org.apache.axis.client.Stub)managementService).setTimeout(timeout);
	// }
	return reportScheduler;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:31,代码来源:WSClient.java

示例8: createHttpRequest

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * Creates an HTTP request based on the message context.
 *
 * @param msgContext the Axis message context
 * @return a new {@link HttpRequest} with content and headers populated
 */
private HttpRequest createHttpRequest(MessageContext msgContext)
    throws SOAPException, IOException {
  Message requestMessage =
      Preconditions.checkNotNull(
          msgContext.getRequestMessage(), "Null request message on message context");
  
  // Construct the output stream.
  String contentType = requestMessage.getContentType(msgContext.getSOAPConstants());
  ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE);

  if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
    logger.debug("Compressing request");
    try (GZIPOutputStream gzipOs = new GZIPOutputStream(bos, BUFFER_SIZE)) {
      requestMessage.writeTo(gzipOs);
    }
  } else {
    logger.debug("Not compressing request");
    requestMessage.writeTo(bos);
  }

  HttpRequest httpRequest =
      requestFactory.buildPostRequest(
          new GenericUrl(msgContext.getStrProp(MessageContext.TRANS_URL)),
          new ByteArrayContent(contentType, bos.toByteArray()));

  int timeoutMillis = msgContext.getTimeout();
  if (timeoutMillis >= 0) {
    logger.debug("Setting read and connect timeout to {} millis", timeoutMillis);
    // These are not the same, but MessageContext has only one definition of timeout.
    httpRequest.setReadTimeout(timeoutMillis);
    httpRequest.setConnectTimeout(timeoutMillis);
  }

  // Copy the request headers from the message context to the post request.
  setHttpRequestHeaders(msgContext, httpRequest);

  return httpRequest;
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:45,代码来源:HttpHandler.java

示例9: setHttpRequestHeaders

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/** Sets HTTP request headers based on the Axis message context. */
private void setHttpRequestHeaders(MessageContext msgContext, HttpRequest httpRequest) {
  @SuppressWarnings("unchecked")
  Map<Object, Object> requestHeaders =
      (Map<Object, Object>) msgContext.getProperty(HTTPConstants.REQUEST_HEADERS);
  if (requestHeaders != null) {
    for (Entry<Object, Object> headerEntry : requestHeaders.entrySet()) {
      Object headerKey = headerEntry.getKey();
      if (headerKey == null) {
        continue;
      }
      String headerName = headerKey.toString().trim();
      Object headerValue = headerEntry.getValue();
      if (HTTPConstants.HEADER_AUTHORIZATION.equals(headerName)
          && (headerValue instanceof String)) {
        // HttpRequest expects the Authorization header to be a list of values,
        // so handle the case where it is simply a string.
        httpRequest.getHeaders().setAuthorization((String) headerValue);
      } else {
        httpRequest.getHeaders().set(headerName, headerValue);
      }
    }
  }
  if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
    httpRequest.getHeaders().setContentEncoding(HTTPConstants.COMPRESSION_GZIP);
  }
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:28,代码来源:HttpHandler.java

示例10: putAllHttpHeaders

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * @see SoapClientHandler#putAllHttpHeaders(Object, Map)
 */
@Override
public void putAllHttpHeaders(Stub soapClient, Map<String, String> headersMap) {
  @SuppressWarnings("unchecked")
  Hashtable<String, String> headers =
      (Hashtable<String, String>) soapClient._getProperty(HTTPConstants.REQUEST_HEADERS);
  if (headers == null) {
    headers = new Hashtable<String, String>();
  }
  headers.putAll(headersMap);
  soapClient._setProperty(HTTPConstants.REQUEST_HEADERS, headers);
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:15,代码来源:AxisHandler.java

示例11: testInvokeReturnsNonXmlResponse

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的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);
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:19,代码来源:HttpHandlerTest.java

示例12: testInvokeWithoutContentType

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的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);
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:16,代码来源:HttpHandlerTest.java

示例13: create

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * Creates a socket.
 * 
 * @param host
 * @param port
 * @param otherHeaders
 * @param useFullURL
 * @return Socket
 * @throws Exception
 */
@Override
public Socket create(String host, int port, StringBuffer otherHeaders, BooleanHolder useFullURL) throws Exception
{

	int timeout = 0;
	if( attributes != null )
	{
		String value = (String) attributes.get(CONNECT_TIMEOUT);
		timeout = (value != null) ? Integer.parseInt(value) : 0;
	}

	TransportClientProperties tcp = TleTransportClientPropertiesFactory.create("http"); //$NON-NLS-1$

	Socket sock = null;
	boolean hostInNonProxyList = isHostInNonProxyList(host, tcp.getNonProxyHosts());

	if( tcp.getProxyUser().length() != 0 )
	{
		StringBuilder tmpBuf = new StringBuilder();

		tmpBuf.append(tcp.getProxyUser()).append(":").append(tcp.getProxyPassword());
		otherHeaders.append(HTTPConstants.HEADER_PROXY_AUTHORIZATION).append(": Basic ")
			.append(Base64.encode(tmpBuf.toString().getBytes())).append("\r\n");
	}
	if( port == -1 )
	{
		port = 80;
	}
	if( (tcp.getProxyHost().length() == 0) || (tcp.getProxyPort().length() == 0) || hostInNonProxyList )
	{
		sock = create(host, port, timeout);
		if( log.isDebugEnabled() )
		{
			log.debug(Messages.getMessage("createdHTTP00"));
		}
	}
	else
	{
		sock = create(tcp.getProxyHost(), new Integer(tcp.getProxyPort()).intValue(), timeout);
		if( log.isDebugEnabled() )
		{
			log.debug(Messages.getMessage("createdHTTP01", tcp.getProxyHost(), tcp.getProxyPort()));
		}
		useFullURL.value = true;
	}
	return sock;
}
 
开发者ID:equella,项目名称:Equella,代码行数:58,代码来源:TleDefaultSocketFactory.java

示例14: createMessageContext

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的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;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:63,代码来源:RPCServer.java

示例15: getSoapAction

import org.apache.axis.transport.http.HTTPConstants; //导入依赖的package包/类
/**
 * Extract the SOAPAction header.
 * if SOAPAction is null then we'll we be forced to scan the body for it.
 * if SOAPAction is "" then use the URL
 * @param req incoming request
 * @return the action
 * @throws AxisFault
 */
private String getSoapAction(HttpServletRequest req) throws AxisFault {
	String soapAction = req.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
	if (soapAction == null) {
		String contentType = req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE);
		if(contentType != null) {
			int index = contentType.indexOf("action");
			if(index != -1){
				soapAction = contentType.substring(index + 7);
			}
		}
	}

	if (isDebug) {
		log.debug("HEADER_SOAP_ACTION:" + soapAction);

		/**
		 * Technically, if we don't find this header, we should probably fault.
		 * It's required in the SOAP HTTP binding.
		 */
	}
	if (soapAction == null) {
		AxisFault af = new AxisFault("Client.NoSOAPAction",
									 Messages.getMessage("noHeader00",
				"SOAPAction"),
									 null, null);

		exceptionLog.error(Messages.getMessage("genFault00"), af);

		throw af;
	}
	// the SOAP 1.1 spec & WS-I 1.0 says:
	// soapaction	= "SOAPAction" ":" [ <"> URI-reference <"> ]
	// some implementations leave off the quotes
	// we strip them if they are present
	if (soapAction.startsWith("\"") && soapAction.endsWith("\"")
		&& soapAction.length() >= 2) {
		int end = soapAction.length() - 1;
		soapAction = soapAction.substring(1, end);
	}

	if (soapAction.length() == 0) {
		soapAction = req.getContextPath(); // Is this right?

	}
	return soapAction;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:55,代码来源:RPCServer.java


注:本文中的org.apache.axis.transport.http.HTTPConstants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。