本文整理汇总了Java中org.springframework.ws.soap.saaj.SaajSoapMessage类的典型用法代码示例。如果您正苦于以下问题:Java SaajSoapMessage类的具体用法?Java SaajSoapMessage怎么用?Java SaajSoapMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaajSoapMessage类属于org.springframework.ws.soap.saaj包,在下文中一共展示了SaajSoapMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doWithMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的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
示例2: doWithMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的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
示例3: doWithMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的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
示例4: formatDate
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
private void formatDate(SaajSoapMessage saajMsg, Date date) throws TransformerException {
if (date == null) {
return;
}
SOAPPart soapPart = saajMsg.getSaajMessage().getSOAPPart();
Source source = new DOMSource(soapPart);
StringResult stringResult = new StringResult();
TransformerFactory.newInstance().newTransformer().transform(source, stringResult);
try {
String from = dateWithTimezone.format(date);
String to = dateWithoutTimezone.format(date);
String content = StringUtils.replace(stringResult.toString(), from, to);
soapPart.setContent(new StringSource(content));
} catch (Exception e) {
throw new TransformerException(e);
}
}
开发者ID:nortal,项目名称:j-road,代码行数:18,代码来源:KirXTeeServiceImpl.java
示例5: substitute
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的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
示例6: doWithMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的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
示例7: logMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的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
示例8: testExtractDataBase64PEMFormat
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
@Test
public void testExtractDataBase64PEMFormat() throws IOException, SOAPException {
// xml elements in a single row, but base64binary part on different rows (PEM format)
XRoadMessage message1 = EXTRACTOR.extractData(new SaajSoapMessage(getMessageFromString("extractor/EarestFail1.xml")));
assertEquals(RESULT_PEM_FORMAT, message1.getContent().toString());
// manually formated file with whitespaces between elements without new row (base64binary in PEM format)
XRoadMessage message2 = EXTRACTOR.extractData(new SaajSoapMessage(getMessageFromString("extractor/EarestFail2.xml")));
assertEquals(RESULT_PEM_FORMAT, message2.getContent().toString());
// menually formated file without whitespaces between elements and without new row (base64binary in PEM format)
XRoadMessage message3 = EXTRACTOR.extractData(new SaajSoapMessage(getMessageFromString("extractor/EarestFail3.xml")));
assertEquals(RESULT_PEM_FORMAT, message3.getContent().toString());
// menually formated file with whitespaces between elements and without new row (base64binary in PEM format)
XRoadMessage message5 = EXTRACTOR.extractData(new SaajSoapMessage(getMessageFromString("extractor/EarestFail5.xml")));
assertEquals(RESULT_PEM_FORMAT, message5.getContent().toString());
}
开发者ID:nortal,项目名称:j-road,代码行数:19,代码来源:StandardXRoadConsumerMessageExtractorTest.java
示例9: getSOAPEnvelope
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
/**
* Gets original SOAP envelope.
*
* @param exchange the exchange
* @return envelope as string or {@code null} if input message isn't Spring web service message
*/
@Nullable
public static String getSOAPEnvelope(Exchange exchange) {
if (! (exchange.getIn() instanceof SpringWebserviceMessage)) {
return null;
}
try {
TransformerFactory tranFactory = TransformerFactory.newInstance();
Transformer aTransformer = tranFactory.newTransformer();
SpringWebserviceMessage inMsg = (SpringWebserviceMessage) exchange.getIn();
Source source = ((SaajSoapMessage) inMsg.getWebServiceMessage()).getEnvelope().getSource();
StringResult strRes = new StringResult();
aTransformer.transform(source, strRes);
return strRes.toString();
} catch (Exception ex) {
throw new IllegalStateException("Error occurred during conversion SOAP envelope to string", ex);
}
}
开发者ID:integram,项目名称:cleverbus,代码行数:28,代码来源:MessageTransformer.java
示例10: handleRequest
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws IOException, SAXException, TransformerException {
// validate payload
boolean reqValResult = super.handleRequest(messageContext, endpoint);
// validate header
if (reqValResult && validateHeader && !ignoreRequest(messageContext)) {
SaajSoapMessage soapMessage = (SaajSoapMessage) messageContext.getRequest();
SoapHeader soapHeader = soapMessage.getSoapHeader();
ValidationIntegrationException[] errors = validateHeader(soapHeader);
if (!ObjectUtils.isEmpty(errors)) {
return handleHeaderValidationErrors(messageContext, errors);
} else if (logger.isDebugEnabled()) {
logger.debug("Request header validated");
}
}
return reqValResult;
}
开发者ID:integram,项目名称:cleverbus,代码行数:23,代码来源:HeaderAndPayloadValidatingInterceptor.java
示例11: doWithMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
@Override
public void doWithMessage(WebServiceMessage request) throws IOException, TransformerException {
SaajSoapMessage message = (SaajSoapMessage) request;
SOAPMessage mes = message.getSaajMessage();
try {
mes.getSOAPPart().getEnvelope().addNamespaceDeclaration(StandardXRoadConsumer.ROOT_NS,
metadata.getRequestElementNs());
getMarshaller().marshal(object, new DOMResult(mes.getSOAPBody()));
} catch (SOAPException e) {
throw new RuntimeException("Invalid SOAP message");
}
callback.doWithMessage(request);
}
开发者ID:nortal,项目名称:j-road,代码行数:15,代码来源:StandardXRoadConsumerCallback.java
示例12: handleResponse
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
@Override
public boolean handleResponse(MessageContext messageContext, Object o) throws Exception {
WebServiceMessage response = messageContext.getResponse();
SaajSoapMessage saajSoapMessage = (SaajSoapMessage) response;
SOAPMessage soapMessage = saajSoapMessage.getSaajMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
Iterator responses = body.getChildElements(new QName(
"http://xroad.vrk.fi/xroad-catalog-lister",
"GetWsdlResponse"));
while (responses.hasNext()) {
Node wsdlResponse = (Node) responses.next();
NodeList children = wsdlResponse.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getLocalName().equals("wsdl")) {
CDATASection cdat = soapPart.createCDATASection(child.getFirstChild().getNodeValue());
child.removeChild(child.getFirstChild());
child.appendChild(cdat);
}
}
}
return true;
}
开发者ID:vrk-kpa,项目名称:xroad-catalog,代码行数:28,代码来源:WsdlCdataInterceptor.java
示例13: testResolveFault_HTTPException
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
/**
* Test method for
* {@link py.una.pol.karaku.services.client.KarakuFaultMessageResolver#resolveFault(org.springframework.ws.WebServiceMessage)}
* .
*/
@Test
public void testResolveFault_HTTPException() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(HTTPExceptionDTO.class);
KarakuFaultMessageResolver resolver = new KarakuFaultMessageResolver(
marshaller);
// @formatter:off
SOAPMessage message = getFromString(""
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
" <SOAP-ENV:Header/> " +
" <SOAP-ENV:Body> " +
" <SOAP-ENV:Fault> " +
" <faultcode>SOAP-ENV:Client</faultcode> " +
" <faultstring xml:lang=\"en\">Invalid request</faultstring> " +
" <detail> " +
" <ns4:HTTPException xmlns:ns4=\"http://sigh.med.una.py/2013/schemas/base\"> " +
" <code>1</code>" +
" <summary>2</summary>" +
" </ns4:HTTPException>" +
" </detail>" +
" </SOAP-ENV:Fault>" +
" </SOAP-ENV:Body>" +
"</SOAP-ENV:Envelope>");
// @formatter:on
SaajSoapMessage ssm = new SaajSoapMessage(message);
try {
resolver.resolveFault(ssm);
fail();
} catch (HTTPException exception) {
assertEquals("1", exception.getCode());
assertEquals("2", exception.getShortDescription());
}
}
开发者ID:fpuna-cia,项目名称:karaku,代码行数:42,代码来源:KarakuFaultMessageResolverTest.java
示例14: testResolvXteFault_NormalException
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
@Test
public void testResolvXteFault_NormalException() throws Exception {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(HTTPExceptionDTO.class);
KarakuFaultMessageResolver resolver = new KarakuFaultMessageResolver(
marshaller);
// @formatter:off
SOAPMessage message = getFromString(""
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
" <SOAP-ENV:Header/> " +
" <SOAP-ENV:Body> " +
" <SOAP-ENV:Fault> " +
" <faultcode>SOAP-ENV:Client</faultcode> " +
" <faultstring xml:lang=\"en\">Invalid request</faultstring> " +
" </SOAP-ENV:Fault>" +
" </SOAP-ENV:Body>" +
"</SOAP-ENV:Envelope>");
// @formatter:on
SaajSoapMessage ssm = new SaajSoapMessage(message);
try {
resolver.resolveFault(ssm);
fail();
} catch (SoapFaultClientException exception) {
assertEquals("Client", exception.getFaultCode().getLocalPart());
assertEquals("Invalid request", exception.getFaultStringOrReason());
}
}
开发者ID:fpuna-cia,项目名称:karaku,代码行数:31,代码来源:KarakuFaultMessageResolverTest.java
示例15: doWithMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
try {
SaajSoapMessage saajMessage = (SaajSoapMessage) message;
SOAPMessage soapmess = saajMessage.getSaajMessage();
SOAPEnvelope env = soapmess.getSOAPPart().getEnvelope();
env.addNamespaceDeclaration("eto", "http://producers.etoimik.xtee.riik.ee/producer/etoimik");
} catch (SOAPException e) {
throw new RuntimeException(e);
}
callback.doWithMessage(message);
}
开发者ID:nortal,项目名称:j-road,代码行数:12,代码来源:TarnXTeeServiceImpl.java
示例16: doWithMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
/**
* Execute any number of operations on the supplied <code>message</code>.
*
* @param message the message
* @throws IOException in case of I/O errors
* @throws TransformerException in case of transformation errors
*/
public void doWithMessage(WebServiceMessage message) {
SaajSoapMessage ssm = (SaajSoapMessage) message;
SOAPMessage sm = ssm.getSaajMessage();
try {
ProcessingContext context = this._processor.createProcessingContext(sm);
SOAPMessage secureM = this._processor.secureOutboundMessage(context);
ssm.setSaajMessage(secureM);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:robertoschwald,项目名称:jasig-cas-examples-robertoschwald,代码行数:19,代码来源:WebserviceClientBase.java
示例17: transform
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
private String transform(WebServiceMessage message) {
SaajSoapMessage saajSoapMessage = ((SaajSoapMessage) message);
StringResult stringResult = new StringResult();
try {
transformer.transform(new DOMSource(saajSoapMessage.getDocument()), stringResult);
} catch (TransformerException e) {
throw new RuntimeException(e);
}
return stringResult.toString();
}
开发者ID:koen-serneels,项目名称:ws-proxy,代码行数:11,代码来源:LoggingInterceptor.java
示例18: createAndConfigureWebServiceTemplate
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
private WebServiceTemplate createAndConfigureWebServiceTemplate(final SaajSoapMessage responseMessage,
QName webServiceIdentifier, HttpServletRequest httpServletRequest) {
WebServiceTemplate webServiceTemplate = new WebServiceTemplate(webServiceMessageFactory) {
@Override
protected Object handleError(WebServiceConnection connection, WebServiceMessage request) throws IOException {
HttpResponse httpResponse = ((HttpComponentsConnection) connection).getHttpResponse();
String statusAndCode = httpResponse.getStatusLine().getReasonPhrase() + " - "
+ httpResponse.getStatusLine().getStatusCode();
Charset charset = httpResponse.getEntity().getContentEncoding() != null
&& httpResponse.getEntity().getContentEncoding().getValue() != null ? Charset
.forName(httpResponse.getEntity().getContentEncoding().getValue()) : Charset.defaultCharset();
String response = httpResponse.getEntity() != null ? StreamUtils.copyToString(httpResponse.getEntity()
.getContent(), charset) : "N/A";
throw new WebServiceTransportException("[Status: " + statusAndCode + "] [Reponse " + response + "]");
}
};
webServiceTemplate.setMessageSender(createAndInitWebServiceMessageSender(webServiceIdentifier));
// In case the target endpoint returns a clean SoapFault, the normal response callback is abandoned and the
// FaulMessageResolver is invoked. In this case we want to return the fault unaltered to the client, so we set
// it here as the response.
webServiceTemplate.setFaultMessageResolver(new FaultMessageResolver() {
@Override
public void resolveFault(WebServiceMessage message) throws IOException {
responseMessage.setSaajMessage(((SaajSoapMessage) message).getSaajMessage());
}
});
List<ClientInterceptor> interceptors = new ArrayList<>();
interceptors.add(new HttpRequestHeaderTransfererInterceptor(HttpRequestHeaderTransfererInterceptor
.extractHeaders(httpServletRequest)));
if (config.getCustomClientInterceptors(webServiceIdentifier) != null) {
interceptors.addAll(config.getCustomClientInterceptors(webServiceIdentifier));
}
LOG.debug("Using interceptors:" + Arrays.toString(ClassUtils.toClass(interceptors.toArray())));
webServiceTemplate.setInterceptors(interceptors.toArray(new ClientInterceptor[0]));
return webServiceTemplate;
}
开发者ID:koen-serneels,项目名称:ws-proxy,代码行数:41,代码来源:ForwardingClient.java
示例19: extractData
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
public XRoadMessage<GetSendStatusResponseTypeUnencoded> extractData(WebServiceMessage message) throws IOException, TransformerException {
Attachment attachment = (Attachment) ((SaajSoapMessage) message).getAttachments().next();
String xml = new String(unzipAndDecode(attachment.getInputStream()), DVK_MESSAGE_CHARSET);
final GetSendStatusResponseTypeUnencoded content = getTypeFromXml(addCorrectNamespaces(xml), GetSendStatusResponseTypeUnencoded.class);
return new XmlBeansXRoadMessage<GetSendStatusResponseTypeUnencoded>(content);
}
开发者ID:nortal,项目名称:j-road,代码行数:7,代码来源:DhlXTeeServiceImpl.java
示例20: extractSoapMessage
import org.springframework.ws.soap.saaj.SaajSoapMessage; //导入依赖的package包/类
public static SOAPMessage extractSoapMessage(WebServiceMessage webServiceMessage) {
return ((SaajSoapMessage) webServiceMessage).getSaajMessage();
}
开发者ID:nortal,项目名称:j-road,代码行数:4,代码来源:SOAPUtil.java
注:本文中的org.springframework.ws.soap.saaj.SaajSoapMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论