org.springframework.ws.client.core.WebServiceMessageCallback Java Examples
The following examples show how to use
org.springframework.ws.client.core.WebServiceMessageCallback.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TicketAgentClient.java From spring-ws with MIT License | 6 votes |
@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(); }
Example #2
Source File: StandardXRoadConsumer.java From j-road with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private <I, O> XRoadMessage<O> sendRealRequest(XRoadMessage<I> input, XRoadServiceConfiguration xroadServiceConfiguration, CustomCallback callback, CustomExtractor extractor) throws XRoadServiceConsumptionException { try { // Add any swaref attachments... // First find all Objects. for (XmlObject attachmentObj : XmlBeansUtil.getAllObjects((XmlObject) input.getContent())) { // Introspect all methods, and find the ones that were generated during instrumentation for (Method method : XmlBeansUtil.getSwaRefGetters(attachmentObj)) { // Get the datahandler for the attachment DataHandler handler = (DataHandler) method.invoke(attachmentObj); if (handler != null) { String field = XmlBeansUtil.getFieldName(method); // Check whether the user has set a custom CID, if not, generate a random one and set it String cid = XmlBeansUtil.getCid(attachmentObj, field); if (cid == null) { cid = AttachmentUtil.getUniqueCid(); } else { cid = cid.startsWith("cid:") ? cid.substring(4) : cid; } XmlBeansUtil.setCid(attachmentObj, field, "cid:" + cid); // Add a new attachment to the list input.getAttachments().add(new XRoadAttachment(cid, handler)); } } } XmlBeansXRoadMetadata curdata = metadata.get(xroadServiceConfiguration.getWsdlDatabase().toLowerCase() + xroadServiceConfiguration.getMethod().toLowerCase()); if (curdata == null) { throw new IllegalStateException(String.format("Could not find metadata for %s.%s! Most likely the method name has been specified incorrectly.", xroadServiceConfiguration.getWsdlDatabase().toLowerCase(), xroadServiceConfiguration.getMethod().toLowerCase())); } WebServiceMessageCallback originalCallback = getNewConsumerCallback(input, xroadServiceConfiguration, curdata); WebServiceMessageExtractor originalExtractor = new StandardXRoadConsumerMessageExtractor(curdata); if (callback != null) { callback.setOriginalCallback(originalCallback); } WebServiceMessageCallback finalCallback = callback == null ? originalCallback : callback; if (extractor != null) { extractor.setOriginalExtractor(originalExtractor); } WebServiceMessageExtractor finalExtractor = extractor == null ? originalExtractor : extractor; return (XRoadMessage<O>) getWebServiceTemplate().sendAndReceive(xroadServiceConfiguration.getSecurityServer(), finalCallback, finalExtractor); } catch (Exception e) { XRoadServiceConsumptionException consumptionException = resolveException(e, xroadServiceConfiguration); if (consumptionException != null) { throw consumptionException; } throw new NestableRuntimeException(e); } }
Example #3
Source File: CustomCallback.java From j-road with Apache License 2.0 | 4 votes |
public void setOriginalCallback(WebServiceMessageCallback callback) { this.callback = callback; }