public void setPayload(Object arg0, JAXBContext arg1) { try { W3CDOMStreamWriter writer = new W3CDOMStreamWriter(); arg1.createMarshaller().marshal(arg0, writer); Source source = new DOMSource(writer.getDocument().getDocumentElement()); setPayload(source); } catch (JAXBException e) { throw new WebServiceException(e); } }
@Override public Exception call() throws Exception { try { if ( log.isBasic() ) { log.logBasic( BaseMessages.getString( PKG, "PurRepositoryConnector.CreateRepositorySyncWebService.Start" ) ); } IRepositorySyncWebService syncWebService = serviceManager.createService( username, decryptedPassword, IRepositorySyncWebService.class ); //$NON-NLS-1$ if ( log.isBasic() ) { log.logBasic( BaseMessages.getString( PKG, "PurRepositoryConnector.CreateRepositorySyncWebService.Sync" ) ); //$NON-NLS-1$ } syncWebService.sync( repositoryMeta.getName(), repositoryMeta.getRepositoryLocation().getUrl() ); } catch ( RepositorySyncException e ) { log.logError( e.getMessage(), e ); // this message will be presented to the user in spoon result.setConnectMessage( e.getMessage() ); return null; } catch ( ClientTransportException e ) { // caused by authentication errors, etc return e; } catch ( WebServiceException e ) { // if we can speak to the repository okay but not the sync service, assume we're talking to a BA Server log.logError( e.getMessage(), e ); return new Exception( BaseMessages.getString( PKG, "PurRepository.BAServerLogin.Message" ), e ); } return null; } } );
@Override public T run() { try { return jaxbContext.createUnmarshaller().unmarshal(source, endpointReferenceClass).getValue(); } catch (final JAXBException e) { throw new WebServiceException("Error unmarshalling NativeEndpointReference ", e); } catch (final ClassCastException e) { throw new WebServiceException("Source did not contain NativeEndpointReference", e); } }
if (idx < 0) { String xml = StaxUtils.toString(el); throw new WebServiceException( BundleUtils.getFormattedString(BUNDLE, "NOT_A_QNAME_PATTER", ns = pfx; if (!ns.equals(comp.getNamespaceURI())) { return false; if (localPart.contains("*")) { return Pattern.matches(mapPattern(localPart), comp.getLocalPart()); } else if (!localPart.equals(comp.getLocalPart())) { return false;
try { Definition def = wsdlManager.getDefinition(wsdlDocumentLocation); interfaceName = def.getService(serviceName).getPort(portName.getLocalPart()).getBinding() .getPortType().getQName(); } catch (Exception e) { ? serviceName.getNamespaceURI() + " " + wsdlDocumentLocation : wsdlDocumentLocation; writer.writeNamespace(JAXWSAConstants.WSDLI_PFX, JAXWSAConstants.WSAM_INTERFACE_NAME, JAXWSAConstants.NS_WSAM); String portTypePrefix = interfaceName.getPrefix(); if (portTypePrefix == null || portTypePrefix.isEmpty()) { portTypePrefix = "ns1"; throw new WebServiceException(new Message("ERROR_UNMARSHAL_ENDPOINTREFERENCE", LOG).toString(), e);
javax.wsdl.Service serv = def.getService(serviceName); if (serv == null) { throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL); QName name = new QName(serviceName.getNamespaceURI(), port.getName());
@NotNull @Override public String getEPRAddress(Packet p, WSEndpoint endpoint) { PortAddressResolver resolver = httpAdapter.owner.createPortAddressResolver(getBaseAddress(), endpoint.getImplementationClass()); String address = resolver.getAddressFor(endpoint.getServiceName(), endpoint.getPortName().getLocalPart()); if (address == null) { throw new WebServiceException("WsservletMessages.SERVLET_NO_ADDRESS_AVAILABLE(" + endpoint.getPortName() + ")"); } return address; }
@Test public void testTimeout() throws Exception { System.getProperties().remove("com.sun.CORBA.POA.ORBServerId"); System.getProperties().remove("com.sun.CORBA.POA.ORBPersistentServerPort"); System.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB"); System.setProperty("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton"); System.setProperty("jacorb.connection.client.pending_reply_timeout", "1000"); URL wsdlUrl = this.getClass().getResource("/wsdl_systest/hello_world_corba_timeout.wsdl"); new SpringBusFactory().createBus("org/apache/cxf/systest/corba/hello_world_client.xml"); GreeterCORBAService gcs = new GreeterCORBAService(wsdlUrl, SERVICE_NAME); Greeter port = gcs.getPort(new QName("http://cxf.apache.org/hello_world_corba", "GreeterTimeoutCORBAPort"), GreeterCORBAService.GreeterProxy.class); try { port.greetMe("Betty"); fail("Should throw org.omg.CORBA.TIMEOUT exception"); } catch (WebServiceException e) { assertTrue(e.getCause() instanceof TIMEOUT); } finally { System.getProperties().remove("org.omg.CORBA.ORBClass"); System.getProperties().remove("org.omg.CORBA.ORBSingletonClass"); System.setProperty("org.omg.CORBA.ORBClass", "com.sun.corba.se.impl.orb.ORBImpl"); } }
private final static QName YOURWEBSERVICE_QNAME = new QName("http://test.webservice.services.xyz.com/", "YourService"); WebServiceException e = null; if (YOURWEBSERVICE_WSDL_LOCATION == null) { e = new WebServiceException("Cannot find '/META-INF/wsdl/YourService.wsdl' wsdl. Place the resource correctly in the classpath."); return super.getPort(new QName("http://test.webservice.services.xyz.com/", "YourServicePort"), YourService.class); return super.getPort(new QName("http://test.webservice.services.xyz.com/", "YourServicePort"), YourService.class, features);
protected static void failWithLocalName(String key, XMLStreamReader reader, String arg) { String msg = key + reader.getLocation().getLineNumber() + reader.getLocalName() + arg; throw new WebServiceException(msg); }
private void init(@Nullable MessageHeaders headers, @NotNull AttachmentSet attachmentSet, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion) { this.headers = headers; this.attachmentSet = attachmentSet; this.reader = reader; if(reader.getEventType()== START_DOCUMENT) XMLStreamReaderUtil.nextElementContent(reader); //if the reader is pointing to the end element </soapenv:Body> then its empty message // or no payload if(reader.getEventType() == XMLStreamConstants.END_ELEMENT){ String body = reader.getLocalName(); String nsUri = reader.getNamespaceURI(); assert body != null; assert nsUri != null; //if its not soapenv:Body then throw exception, we received malformed stream if(body.equals("Body") && nsUri.equals(soapVersion.nsUri)){ this.payloadLocalName = null; this.payloadNamespaceURI = null; }else{ //TODO: i18n and also we should be throwing better message that this throw new WebServiceException("Malformed stream: {"+nsUri+"}"+body); } }else{ this.payloadLocalName = reader.getLocalName(); this.payloadNamespaceURI = reader.getNamespaceURI(); } // use the default infoset representation for headers int base = soapVersion.ordinal()*3; this.envelopeTag = DEFAULT_TAGS.get(base); this.headerTag = DEFAULT_TAGS.get(base+1); this.bodyTag = DEFAULT_TAGS.get(base+2); }
private static JAXBContext getJAXBContext() { if (jaxbContext == null) { try { jaxbContext = JAXBContext.newInstance(W3CEndpointReference.class); } catch (JAXBException e) { throw new WebServiceException(new Message("JAXBCONTEXT_CREATION_FAILED", LOG).toString(), e); } } return jaxbContext; } }
fail("Did not receive expected Exception."); } catch (WebServiceException wse) { SoapFault sf = (SoapFault)wse.getCause(); assertEquals("Server", sf.getFaultCode().getLocalPart());
protected static void failWithFullName(String key, XMLStreamReader reader) { String msg = key + reader.getLocation().getLineNumber() + reader.getName(); throw new WebServiceException(msg); }
public static WSDLModel parse(@Nullable URL wsdlLoc, @NotNull Source wsdlSource, @NotNull EntityResolver resolver, boolean isClientSide, Container container, Class serviceClass, @NotNull PolicyResolver policyResolver, boolean isUseStreamFromEntityResolverWrapper, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { if(!hasWSDLDefinitions(parser.parser)){ throw new XMLStreamException(ClientMessages.RUNTIME_WSDLPARSER_INVALID_WSDL(parser.systemId, WSDLConstants.QNAME_DEFINITIONS, parser.parser.getName(), parser.parser.getLocation())); throw new WebServiceException(ClientMessages.WSDL_CONTAINS_NO_SERVICE(wsdlLoc));
public Object[] getHeaders(QName name, JAXBContext context, boolean allRoles) { SOAPMessage msg = getMessage(); SOAPHeader header; try { header = msg.getSOAPPart().getEnvelope().getHeader(); if (header == null || !header.hasChildNodes()) { return new Object[0]; } List<Object> ret = new ArrayList<>(); Iterator<SOAPHeaderElement> it = CastUtils.cast(header.examineAllHeaderElements()); while (it.hasNext()) { SOAPHeaderElement she = it.next(); if ((allRoles || roles.contains(she.getActor())) && name.equals(she.getElementQName())) { ret.add(JAXBUtils.unmarshall(context, she)); } } return ret.toArray(new Object[0]); } catch (SOAPException | JAXBException e) { throw new WebServiceException(e); } }
configureObject(portName.toString() + ".jaxws-client.proxyFactory", clientFac); throw new WebServiceException(e);
protected static void fail(String key, XMLStreamReader reader) { String msg = key + reader.getLocation().getLineNumber(); logger.log(Level.SEVERE, msg); throw new WebServiceException(msg); }
public static @Nullable <F extends WebServiceFeature> F mergeFeature(final @NotNull Class<F> featureType, @Nullable WebServiceFeatureList list1, @Nullable WebServiceFeatureList list2) throws WebServiceException { final F feature1 = list1 != null ? list1.get(featureType) : null; final F feature2 = list2 != null ? list2.get(featureType) : null; if (feature1 == null) { return feature2; } else if (feature2 == null) { return feature1; } else { if (feature1.equals(feature2)) { return feature1; } else { // TODO exception text throw new WebServiceException(feature1 + ", " + feature2); } } }
/** * Gets the corresponding {@link AddressingVersion} instance from the * EPR class. */ public static @NotNull AddressingVersion fromSpecClass(Class<? extends EndpointReference> eprClass) { if(eprClass==W3CEndpointReference.class) return W3C; if(eprClass==MemberSubmissionEndpointReference.class) return MEMBER; throw new WebServiceException("Unsupported EPR type: "+eprClass); }