use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.
the class WebServiceFeatureList method parseAnnotations.
/**
* @param endpointClass web service impl class
*/
public void parseAnnotations(Class<?> endpointClass) {
for (Annotation a : endpointClass.getAnnotations()) {
WebServiceFeature ftr = getFeature(a);
if (ftr != null) {
if (ftr instanceof MTOMFeature) {
// check conflict with @BindingType
BindingID bindingID = BindingID.parse(endpointClass);
MTOMFeature bindingMtomSetting = bindingID.createBuiltinFeatureList().get(MTOMFeature.class);
if (bindingMtomSetting != null && bindingMtomSetting.isEnabled() ^ ftr.isEnabled()) {
throw new RuntimeModelerException(ModelerMessages.RUNTIME_MODELER_MTOM_CONFLICT(bindingID, ftr.isEnabled()));
}
}
add(ftr);
}
}
}
use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.
the class MtomFeatureConfigurator method getFeatures.
/**
* process Mtom policy assertions and if found and is not optional then mtom is enabled on the
* {@link WSDLBoundPortType}
*
* @param key Key that identifies the endpoint scope
* @param policyMap Must be non-null
* @throws PolicyException If retrieving the policy triggered an exception
*/
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
final Collection<WebServiceFeature> features = new LinkedList<>();
if ((key != null) && (policyMap != null)) {
Policy policy = policyMap.getEndpointEffectivePolicy(key);
if (null != policy && policy.contains(EncodingConstants.OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
Iterator<AssertionSet> assertions = policy.iterator();
while (assertions.hasNext()) {
AssertionSet assertionSet = assertions.next();
Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
while (policyAssertion.hasNext()) {
PolicyAssertion assertion = policyAssertion.next();
if (EncodingConstants.OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())) {
features.add(new MTOMFeature(true));
}
// end-if non optional mtom assertion found
}
// next assertion
}
// next alternative
}
// end-if policy contains mtom assertion
}
return features;
}
use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.
the class MtomPolicyMapConfigurator method update.
/**
* Generates an MTOM policy if MTOM is enabled.
*
* <ol>
* <li>If MTOM is enabled
* <ol>
* <li>If MTOM policy does not already exist, generate
* <li>Otherwise do nothing
* </ol>
* <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
* </ol>
*/
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
LOGGER.entering(policyMap, model, wsBinding);
Collection<PolicySubject> subjects = new ArrayList<>();
if (policyMap != null) {
final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("mtomFeature = " + mtomFeature);
}
if ((mtomFeature != null) && mtomFeature.isEnabled()) {
final QName bindingName = model.getBoundPortTypeName();
final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
final Policy mtomPolicy = createMtomPolicy(bindingName);
final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
subjects.add(mtomPolicySubject);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
}
}
}
// endif policy map not null
LOGGER.exiting(subjects);
return subjects;
}
use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.
the class StreamMessageTest method testWriteSwaToStreamClientRequest.
// Bug 17367334
public void testWriteSwaToStreamClientRequest() throws Exception {
String ctype = "multipart/related; boundary=MIME_Boundary; " + "start=\"<6232425701115978772--54bee05.140acdf4f8a.-7f3f>\"; " + "type=\"text/xml\"; start-info=\"text/xml\"";
MessageContextFactory mcf = MessageContextFactory.createFactory(new MTOMFeature(true));
InputStream is = getClass().getClassLoader().getResourceAsStream("etc/bug17367334InputMsg.txt");
Packet packet = (Packet) mcf.createContext(is, ctype);
Message message = packet.getInternalMessage();
assertTrue("StreamMessage not found, got : " + message.getClass(), StreamMessage.class.isAssignableFrom(message.getClass()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
packet.setState(State.ClientRequest);
// System.out.println("SWA packet.getContentType(): " + packet.getContentType().getContentType() );
ContentType contentType = packet.writeTo(baos);
// System.out.println("etc/bug17367334InputMsg.txt\r\n" + contentType.getContentType() + "\r\n" + new String(baos.toByteArray()));
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
MessageFactory mf = MessageFactory.newInstance();
MimeHeaders mh = new MimeHeaders();
mh.addHeader("Content-Type", ctype);
SOAPMessage sm = mf.createMessage(mh, bais);
assertEquals("wrong attachment count", 1, sm.countAttachments());
AttachmentPart ap = (AttachmentPart) sm.getAttachments().next();
assertEquals("wrong attachemnt Content-Id", "<testAttachmentContentId>", ap.getContentId());
// NodeList nl = sm.getSOAPBody().getElementsByTagNameNS(MtomCodec.XOP_NAMESPACEURI, MtomCodec.XOP_LOCALNAME);
}
use of jakarta.xml.ws.soap.MTOMFeature in project metro-jax-ws by eclipse-ee4j.
the class MtomAppTest method testUpload.
public void testUpload() throws Exception {
Hello port = new HelloService().getHelloPort(new MTOMFeature());
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
Holder<Integer> total = new Holder<Integer>(123456000);
Holder<String> name = new Holder<String>("huge");
Holder<DataHandler> dh = new Holder<DataHandler>(getDataHandler(total.value));
port.upload(total, name, dh);
if (!"hugehuge".equals(name.value)) {
fail("FAIL: Expecting: hugehuge Got: " + name.value);
}
System.out.println("SUCCESS: Got: " + name.value);
System.out.println("Going to verify DataHandler. This would take some time");
validateDataHandler(total.value, dh.value);
System.out.println("SUCCESS: DataHandler is verified");
}
Aggregations