/** * Puts an addressing policy into the PolicyMap if the addressing feature was set. */ public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding) throws PolicyException { LOGGER.entering(policyMap, model, wsBinding); Collection<PolicySubject> subjects = new ArrayList<PolicySubject>(); if (policyMap != null) { final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("addressingFeature = " + addressingFeature); } if ((addressingFeature != null) && addressingFeature.isEnabled()) { //add wsam:Addrressing assertion if not exists. addWsamAddressing(subjects, policyMap, model, addressingFeature); } } // endif policy map not null LOGGER.exiting(subjects); return subjects; }
public <T> Dispatch<T> createDispatch(QName portName, Class<T> aClass, Service.Mode mode, WebServiceFeatureList features) { WSEndpointReference wsepr = null; boolean isAddressingEnabled = false; AddressingFeature af = features.get(AddressingFeature.class); if (af == null) { af = this.features.get(AddressingFeature.class); } if (af != null && af.isEnabled()) isAddressingEnabled = true; MemberSubmissionAddressingFeature msa = features.get(MemberSubmissionAddressingFeature.class); if (msa == null) { msa = this.features.get(MemberSubmissionAddressingFeature.class); } if (msa != null && msa.isEnabled()) isAddressingEnabled = true; if(isAddressingEnabled && wsdlService != null && wsdlService.get(portName) != null) { wsepr = wsdlService.get(portName).getEPR(); } return createDispatch(portName, wsepr, aClass, mode, features); }
protected Dispatch<Object> createDispatch(QName portName, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeatureList features) { WSEndpointReference wsepr = null; boolean isAddressingEnabled = false; AddressingFeature af = features.get(AddressingFeature.class); if (af == null) { af = this.features.get(AddressingFeature.class); } if (af != null && af.isEnabled()) isAddressingEnabled = true; MemberSubmissionAddressingFeature msa = features.get(MemberSubmissionAddressingFeature.class); if (msa == null) { msa = this.features.get(MemberSubmissionAddressingFeature.class); } if (msa != null && msa.isEnabled()) isAddressingEnabled = true; if(isAddressingEnabled && wsdlService != null && wsdlService.get(portName) != null) { wsepr = wsdlService.get(portName).getEPR(); } return createDispatch(portName, wsepr, jaxbContext, mode, features); }
public void testInvalidAddressingFeature() { // Use the default feature config AddressingFeature feature = new AddressingFeature(); Service svc = Service.create(new QName("http://test", "ProxyAddressingService")); ProxyAddressingService proxy = svc.getPort(subEPR, ProxyAddressingService.class, feature); assertNotNull(proxy); try { proxy.doSomething("12345"); fail("An exception should have been thrown"); } catch (WebServiceException wse) { //pass } catch (Exception e) { fail("The wrong exception type was thrown."); } }
public void testInvalidAddressingFeature() { // Use the default feature config AddressingFeature feature = new AddressingFeature(); Service svc = Service.create(new QName("http://test", "TestService")); svc.addPort(new QName("http://test", "TestPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://localhost"); Dispatch<Source> d = svc.createDispatch(subEPR, Source.class, Service.Mode.PAYLOAD, feature); try { d.invoke(null); fail("An exception should have been thrown"); } catch (WebServiceException wse) { //pass } catch (Exception e) { fail("The wrong exception type was thrown."); } }
public AddressingVersion getAddressingVersion() { AddressingVersion addressingVersion; if (features.isEnabled(AddressingFeature.class)) addressingVersion = AddressingVersion.W3C; else if (features.isEnabled(MemberSubmissionAddressingFeature.class)) addressingVersion = AddressingVersion.MEMBER; else addressingVersion = null; return addressingVersion; }
private WSDLBoundOperation.ANONYMOUS getResponseRequirement(@Nullable WSDLBoundOperation wbo) { try { if (af.getResponses() == AddressingFeature.Responses.ANONYMOUS) { return WSDLBoundOperation.ANONYMOUS.required; } else if (af.getResponses() == AddressingFeature.Responses.NON_ANONYMOUS) { return WSDLBoundOperation.ANONYMOUS.prohibited; } } catch (NoSuchMethodError e) { //Ignore error, defaut to optional } //wsaw wsdl binding case will have some value set on wbo return wbo != null ? wbo.getAnonymous() : WSDLBoundOperation.ANONYMOUS.optional; }
protected WsaTubeHelper getTubeHelper() { if(binding.isFeatureEnabled(AddressingFeature.class)) { return new WsaTubeHelperImpl(wsdlPort, null, binding); } else if(binding.isFeatureEnabled(MemberSubmissionAddressingFeature.class)) { //seiModel is null as it is not needed. return new com.sun.xml.internal.ws.addressing.v200408.WsaTubeHelperImpl(wsdlPort, null, binding); } else { // Addressing is not enabled, WsaTube should not be included in the pipeline throw new WebServiceException(AddressingMessages.ADDRESSING_NOT_ENABLED(this.getClass().getSimpleName())); } }
private void addWsamAddressing(Collection<PolicySubject> subjects, PolicyMap policyMap, SEIModel model, AddressingFeature addressingFeature) throws PolicyException { final QName bindingName = model.getBoundPortTypeName(); final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName); final Policy addressingPolicy = createWsamAddressingPolicy(bindingName, addressingFeature); final PolicySubject addressingPolicySubject = new PolicySubject(wsdlSubject, addressingPolicy); subjects.add(addressingPolicySubject); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Added addressing policy with ID \"" + addressingPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\""); } }
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) { QName ua = reader.getName(); if (ua.equals(AddressingVersion.W3C.wsdlExtensionTag)) { String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required"); binding.addFeature(new AddressingFeature(true, Boolean.parseBoolean(required))); XMLStreamReaderUtil.skipElement(reader); return true; // UsingAddressing is consumed } return false; }
@Override public void start(WSDLGenExtnContext ctxt) { WSBinding binding = ctxt.getBinding(); TypedXmlWriter root = ctxt.getRoot(); enabled = binding.isFeatureEnabled(AddressingFeature.class); if (!enabled) return; AddressingFeature ftr = binding.getFeature(AddressingFeature.class); required = ftr.isRequired(); root._namespace(AddressingVersion.W3C.wsdlNsUri, AddressingVersion.W3C.getWsdlPrefix()); }