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


Java WebServiceMessage类代码示例

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


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

示例1: testInvalidResponse

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
@Test
	@SuppressWarnings("unused")
	public void testInvalidResponse() throws IOException
	{
		WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
		webServiceTemplate.setCheckConnectionForFault(false);
		MockWebServiceMessageSender messageSender = new MockWebServiceMessageSender();
		DefaultResponseGenerator responseGenerator = new DefaultResponseGenerator();
		responseGenerator.setNeverCreateEnvelope(true);
		SimpleResourceLookup resourceLookup = new SimpleResourceLookup(new ClassPathResource("mock-responses/test/default-response-invalid.xml"));
		resourceLookup.setTemplateProcessor(new TemplateProcessor() {
			public Resource processTemplate(Resource resource, WebServiceMessage message) throws IOException {
				return resource;
			}
		});
		responseGenerator.setResourceLookup(resourceLookup);
		messageSender.setRequestProcessors(Arrays.asList(responseGenerator));
		webServiceTemplate.setMessageSender(messageSender);
		
		Source source = getValidMessage().getPayloadSource(); 
		StringResult result = new StringResult();
		//TODO uncomment
//		webServiceTemplate.sendSourceAndReceiveToResult(TEST_URI.toString(), source, result);		
	}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:25,代码来源:InvalidMessagesTest.java

示例2: transformHeaders

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
protected void transformHeaders(WebServiceMessage reqMessage, WebServiceMessage respMessage)
        throws TransformerException, SOAPException {

    SoapHeader reqHeader = getSoapHeader(reqMessage);
    SoapHeader respHeader = getSoapHeader(respMessage);

    TransformerFactory transformerFactory = TransformerFactory
            .newInstance();
    Transformer transformer = transformerFactory.newTransformer();

    Iterator<SoapHeaderElement> iter = reqHeader.examineAllHeaderElements();
    while (iter.hasNext()) {
        SoapHeaderElement elem = iter.next();
        transformer.transform(elem.getSource(), respHeader.getResult());
    }
}
 
开发者ID:vrk-kpa,项目名称:xroad-catalog,代码行数:17,代码来源:ServiceEndpointInterceptor.java

示例3: listFlights

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<BigInteger> listFlights() {
  ObjectFactory factory = new ObjectFactory();
  TListFlights tListFlights = factory.createTListFlights();

  JAXBElement<TListFlights> request = factory.createListFlightsRequest(tListFlights);

  JAXBElement<TFlightsResponse> response = (JAXBElement<TFlightsResponse>) webServiceTemplate
      .marshalSendAndReceive(request, new WebServiceMessageCallback() {

        public void doWithMessage(WebServiceMessage message) {
          TransportContext context = TransportContextHolder.getTransportContext();
          HttpUrlConnection connection = (HttpUrlConnection) context.getConnection();
          connection.getConnection().addRequestProperty("Authorization",
              BasicAuthenticationUtil.generateBasicAutenticationHeader(clientConfig.getUserName(),
                  clientConfig.getUserPassword()));
        }
      });

  return response.getValue().getFlightNumber();
}
 
开发者ID:code-not-found,项目名称:spring-ws,代码行数:22,代码来源:TicketAgentClient.java

示例4: invoke

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
/**
 * Invoked by Spring-WS when a {@link WebServiceMessage} is received
 */
public void invoke(MessageContext messageContext) throws Exception {
    Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOptionalOut);
    populateExchangeFromMessageContext(messageContext, exchange);

    // start message processing
    getProcessor().process(exchange);

    if (exchange.getException() != null) {
        throw exchange.getException();
    } else if (exchange.getPattern().isOutCapable()) {
        Message responseMessage = exchange.getOut(Message.class);
        if (responseMessage != null) {
            Source responseBody = responseMessage.getBody(Source.class);
            WebServiceMessage response = messageContext.getResponse();

            configuration.getMessageFilter().filterConsumer(exchange, response);

            XmlConverter xmlConverter = configuration.getXmlConverter();
            xmlConverter.toResult(responseBody, response.getPayloadResult());
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:SpringWebserviceConsumer.java

示例5: getMessage

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
/**
 * Retrieves the XML message from the WebServiceMessage obj using the transformer,
 * returns null in case source is null
 * 
 * @param source to retrieve the SOAP message
 * @return String XML formatted
 * @throws Exception
 */
private String getMessage(WebServiceMessage message) throws Exception {
    Source source = message.getPayloadSource();
    if (source != null) {
        Transformer transformer = createNonIndentingTransformer();
        StringWriter writer = new StringWriter();
        transformer.transform(source, new StreamResult(writer));
        
        //Retrieve msg and remove break line if requested
        String msg = writer.toString();  
        if (removeNewline) {
            msg = StringUtils.remove(msg, System.getProperty("line.separator"));
        }
        
        //Return processed message
        return msg;
    }
    return null;
}
 
开发者ID:SpartaTech,项目名称:sparta-spring-webservice-utils,代码行数:27,代码来源:PayloadLoggingClientInterceptor.java

示例6: addSecurity

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
/**
 * Agrega seguridad a una llamada a un servicio, para ello agrega dos header
 * params, pertenecientes a Usuario y Password.
 * 
 * @param user
 *            usuario de la llamada
 * @param password
 *            contraseña del que invoca el servicio.
 * @param message
 *            mensaje que actualmente se esta enviando
 */
public void addSecurity(String user, String password,
		WebServiceMessage message) {

	Charset cs = Charset.forName(CharEncoding.UTF_8);
	TransportContext context = TransportContextHolder.getTransportContext();
	HttpUrlConnection connection = (HttpUrlConnection) context
			.getConnection();
	HttpURLConnection uRLConnection = connection.getConnection();
	String auth = CREDENTIALS_FORMAT.replace("USER", user).replace(
			"PASSWORD", password);
	byte[] encode = Base64.encode(auth.getBytes(cs));
	uRLConnection.addRequestProperty(AUTHORIZATION_HEADER_PARAM,
			HEADER_CREDENTIALS_FORMAT.replace("CREDENTIALS", new String(
					encode, cs)));
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:27,代码来源:WSSecurityInterceptor.java

示例7: resolveFault

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
@Override
public void resolveFault(WebServiceMessage message) throws IOException {

	SoapMessage message2 = (SoapMessage) message;

	SoapBody body = message2.getSoapBody();
	// No Fault object, go to fallback
	if (body.getFault() == null
			|| body.getFault().getFaultDetail() == null
			|| !body.getFault().getFaultDetail().getDetailEntries()
					.hasNext()) {
		fallBack(message2);
	}

	SoapFaultDetail sfd = body.getFault().getFaultDetail();

	tryHttpException(message2, sfd.getDetailEntries().next());

}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:20,代码来源:KarakuFaultMessageResolver.java

示例8: responseMarshaller

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
/**
 * Retorna un {@link ResponseMatcher} que marshaliza el resultado.
 * 
 * <p>
 * Este {@link ResponseMatcher} no realiza ninguna acción, siempre valida y
 * se encarga de parsear el resultado
 * </p>
 * 
 * @return dummy {@link ResponseMatcher}
 */
public ResponseMatcher responseMarshaller() {

	return new ResponseMatcher() {

		@Override
		public void match(WebServiceMessage request,
				WebServiceMessage response) throws IOException,
				AssertionError {

			WebServiceMessage dos = response;
			Source source = dos.getPayloadSource();
			result = unmarshaller.unmarshal(source);
		}
	};
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:26,代码来源:BaseTestWebService.java

示例9: doWithMessage

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
@Override
public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
	callback.doWithMessage(request);

	SaajSoapMessage message = (SaajSoapMessage) request;
	SOAPMessage mes = message.getSaajMessage();

	try {
		SOAPBody body = mes.getSOAPBody();

		SOAPElement queryEle = (SOAPElement) body.getChildElements().next();
		SOAPElement kehaEle = (SOAPElement) queryEle.getChildElements().next();

		java.util.Iterator kehaChilds = kehaEle.getChildElements();
		while (kehaChilds.hasNext()) {
			Object nextEle = kehaChilds.next();
			if (nextEle instanceof SOAPElement) {
				addType((SOAPElement) nextEle);
			}
		}
	} catch(Exception ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:nortal,项目名称:j-road,代码行数:25,代码来源:AarXTeeConsumerCallback.java

示例10: doWithMessage

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
  callback.doWithMessage(message);
  try {
    SaajSoapMessage saajMessage = (SaajSoapMessage) message;
    SOAPMessage soapmess = saajMessage.getSaajMessage();
    SOAPEnvelope env = soapmess.getSOAPPart().getEnvelope();
    env.addNamespaceDeclaration("xro", "http://x-road.ee/xsd/x-road.xsd");
    Iterator headers = env.getHeader().getChildElements();
    while (headers.hasNext()) {
      SOAPElement header = (SOAPElement) headers.next();
      if (header.getNamespaceURI().equalsIgnoreCase("http://x-rd.net/xsd/xroad.xsd")) {
        String localHeaderName = header.getLocalName();
        QName qName = new QName("http://x-road.ee/xsd/x-road.xsd", localHeaderName, "xro");
        header.setElementQName(qName);
      }
    }
  } catch (SOAPException e) {
    throw new RuntimeException(e);
  }

}
 
开发者ID:nortal,项目名称:j-road,代码行数:22,代码来源:Adsv5XTeeServiceImpl.java

示例11: doWithMessage

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
    callback.doWithMessage(message);
    try {
        SaajSoapMessage saajMsg = (SaajSoapMessage) message;
        SOAPMessage soapMsg = saajMsg.getSaajMessage();
        SOAPEnvelope env = soapMsg.getSOAPPart().getEnvelope();
        env.addNamespaceDeclaration(ns, nsV31Uri);

        Iterator headers = env.getHeader().getChildElements();
        while (headers.hasNext()) {
            SOAPElement header = (SOAPElement) headers.next();
            if (header.getNamespaceURI().equalsIgnoreCase(nsV30Uri)) {
                QName qName = new QName(nsV31Uri, header.getLocalName(), ns);
                header.setElementQName(qName);
            }
        }

        formatDate(saajMsg, startDate);
        formatDate(saajMsg, endDate);
    } catch (SOAPException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:nortal,项目名称:j-road,代码行数:24,代码来源:KirXTeeServiceImpl.java

示例12: substitute

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
/**
 * Substitutes all occurences of some given string inside the given {@link WebServiceMessage} with another value.
 *
 * @param message message to substitute in
 * @param from the value to substitute
 * @param to the value to substitute with
 * @throws TransformerException
 */
public static void substitute(WebServiceMessage message, String from, String to) throws TransformerException {
  SaajSoapMessage saajSoapMessage = (SaajSoapMessage) message;
  SOAPPart soapPart = saajSoapMessage.getSaajMessage().getSOAPPart();

  Source source = new DOMSource(soapPart);
  StringResult stringResult = new StringResult();

  TransformerFactory.newInstance().newTransformer().transform(source, stringResult);

  String content = stringResult.toString().replaceAll(from, to);

  try {
    soapPart.setContent(new StringSource(content));
  } catch (SOAPException e) {
    throw new TransformerException(e);
  }
}
 
开发者ID:nortal,项目名称:j-road,代码行数:26,代码来源:SOAPUtil.java

示例13: doWithMessage

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
public void doWithMessage(WebServiceMessage message) {
  SaajSoapMessage saajMessage = (SaajSoapMessage) message;
  try {
    // Add attachments
    if (attachments != null) {
      for (XRoadAttachment attachment : attachments) {
        saajMessage.addAttachment("<" + attachment.getCid() + ">", attachment, attachment.getContentType());
      }
    }
    SOAPMessage soapmess = saajMessage.getSaajMessage();
    SOAPEnvelope env = soapmess.getSOAPPart().getEnvelope();

    protocolVersionStrategy.addNamespaces(env);
    protocolVersionStrategy.addXTeeHeaderElements(env, serviceConfiguration);
  } catch (SOAPException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:nortal,项目名称:j-road,代码行数:19,代码来源:XRoadMessageCallback.java

示例14: logMessage

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
private boolean logMessage(MessageContext mc, MessageType messageType) {
  if (log.isDebugEnabled()) {
    WebServiceMessage message = MessageType.REQUEST.equals(messageType) ? mc.getRequest() : mc.getResponse();

    if (message instanceof SaajSoapMessage) {
      OutputStream out = new ByteArrayOutputStream();
      try {
        ((SaajSoapMessage) message).writeTo(out);
        log.debug(messageType + " message follows:\n" + out.toString());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }

  return true;
}
 
开发者ID:nortal,项目名称:j-road,代码行数:18,代码来源:WSConsumptionLoggingInterceptor.java

示例15: createSoapMessage

import org.springframework.ws.WebServiceMessage; //导入依赖的package包/类
/**
 * Creates a new SOAP message representation from given payload resource. Constructs a SOAP envelope
 * with empty header and payload as body.
 *
 * @param message
 * @return
 * @throws IOException
 */
public Message createSoapMessage(Message message) {
    try {
        String payload = message.getPayload().toString();

        LOG.info("Creating SOAP message from payload: " + payload);

        WebServiceMessage soapMessage = soapMessageFactory.createWebServiceMessage();
        transformerFactory.newTransformer().transform(
                new StringSource(payload), soapMessage.getPayloadResult());

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        soapMessage.writeTo(bos);

        return new SoapMessage(new String(bos.toByteArray()), message.getHeaders());
    } catch (Exception e) {
        throw new CitrusRuntimeException("Failed to create SOAP message from payload resource", e);
    }
}
 
开发者ID:christophd,项目名称:citrus-simulator,代码行数:27,代码来源:SoapMessageHelper.java


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