javax.wsdl.WSDLException Java Examples

The following examples show how to use javax.wsdl.WSDLException. 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: BesDAO.java    From development with Apache License 2.0 7 votes vote down vote up
void validateVersion(String wsdlUrl) {
    WSDLLocator locator = new BasicAuthWSDLLocator(wsdlUrl, null, null);
    WSDLFactory wsdlFactory;
    Definition serviceDefinition;
    try {
        wsdlFactory = WSDLFactory.newInstance();
        WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
        // avoid importing external documents
        wsdlReader.setExtensionRegistry(new WSVersionExtensionRegistry());
        serviceDefinition = wsdlReader.readWSDL(locator);
        Element versionElement = serviceDefinition
                .getDocumentationElement();
        if (!CTMGApiVersion.version.equals(versionElement.getTextContent())) {
            LOGGER.warn("Web service mismatches and the version value, expected: "
                    + CTMGApiVersion.version
                    + " and the one got from wsdl: "
                    + versionElement.getTextContent());
        }
    } catch (WSDLException e) {
        LOGGER.warn("Remote wsdl cannot be retrieved from CT_MG. [Cause: "
                + e.getMessage() + "]", e);
    }

}
 
Example #2
Source File: OperationVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BindingOperation generateBindingOperation(Binding wsdlBinding, Operation op,
                                                  String corbaOpName) {
    BindingOperation bindingOperation = definition.createBindingOperation();
    //OperationType operationType = null;
    try {
        corbaOperation = (OperationType)extReg.createExtension(BindingOperation.class,
                                                               CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException ex) {
        throw new RuntimeException(ex);
    }
    corbaOperation.setName(corbaOpName);
    bindingOperation.addExtensibilityElement((ExtensibilityElement)corbaOperation);
    bindingOperation.setOperation(op);
    bindingOperation.setName(op.getName());
    binding.addBindingOperation(bindingOperation);
    return bindingOperation;
}
 
Example #3
Source File: ReflectionServiceFactorBeanTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testEmptyWsdlAndNoServiceClass() throws Exception {
    final String dummyWsdl = "target/dummy.wsdl";
    ReflectionServiceFactoryBean bean = new ReflectionServiceFactoryBean();
    Bus bus = control.createMock(Bus.class);

    WSDLManager wsdlmanager = control.createMock(WSDLManager.class);
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(wsdlmanager);
    EasyMock.expect(wsdlmanager.getDefinition(dummyWsdl))
        .andThrow(new WSDLException("PARSER_ERROR", "Problem parsing '" + dummyWsdl + "'."));
    EasyMock.expect(bus.getExtension(FactoryBeanListenerManager.class)).andReturn(null);

    control.replay();

    bean.setWsdlURL(dummyWsdl);
    bean.setServiceName(new QName("http://cxf.apache.org/hello_world_soap_http", "GreeterService"));
    bean.setBus(bus);

    try {
        bean.create();
        fail("no valid wsdl nor service class specified");
    } catch (ServiceConstructionException e) {
        // ignore
    }
}
 
Example #4
Source File: XTeeSoapProvider.java    From j-road with Apache License 2.0 6 votes vote down vote up
private List<SOAPHeader> makeHeaders(Definition definition) throws WSDLException {
  List<SOAPHeader> list = new ArrayList<SOAPHeader>();
  String[] parts = new String[] { XTeeHeader.CLIENT.getLocalPart(), XTeeHeader.SERVICE.getLocalPart(),
                                  XTeeHeader.USER_ID.getLocalPart(), XTeeHeader.ID.getLocalPart(),
                                  XTeeHeader.PROTOCOL_VERSION.getLocalPart() };
  ExtensionRegistry extReg = definition.getExtensionRegistry();
  for (int i = 0; i < parts.length; i++) {
    SOAPHeader header =
        (SOAPHeader) extReg.createExtension(BindingInput.class, new QName(SOAP_11_NAMESPACE_URI, "header"));
    header.setMessage(new QName(definition.getTargetNamespace(), XTeeWsdlDefinition.XROAD_HEADER));
    header.setPart(parts[i]);
    if (use.equalsIgnoreCase(LITERAL)) {
      header.setUse(LITERAL);
    } else {
      header.setUse(ENCODED);
      header.setEncodingStyles(Arrays.asList(ENCODING));
    }
    list.add(header);
  }

  return list;
}
 
Example #5
Source File: WSDLCorbaWriterImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Document getDocument(Definition wsdlDef) throws WSDLException {
    try {
        fixTypes(wsdlDef);
    } catch (Exception ex) {
        throw new WSDLException(WSDLException.PARSER_ERROR, ex.getMessage(), ex);
    }
    Document doc = wrapped.getDocument(wsdlDef);
    Element imp = null;
    Element child = DOMUtils.getFirstElement(doc.getDocumentElement());
    //move extensability things to the top
    while (child != null) {
        if (child.getNamespaceURI().equals(doc.getDocumentElement().getNamespaceURI())) {
            //wsdl node
            if (imp == null) {
                imp = child;
            }
        } else if (imp != null) {
            doc.getDocumentElement().removeChild(child);
            doc.getDocumentElement().insertBefore(child, imp);
        }
        child = DOMUtils.getNextElement(child);
    }

    return doc;
}
 
Example #6
Source File: ODEEndpointUpdater.java    From container with Apache License 2.0 6 votes vote down vote up
private Map<QName, List<File>> updateProvidedWSDLAddresses(final Map<QName, List<File>> changeMap) throws WSDLException {
    final Map<QName, List<File>> notChanged = new HashMap<>();
    for (final QName portType : changeMap.keySet()) {
        final List<File> notUpdateWSDLs = new ArrayList<>();

        for (final File wsdlFile : changeMap.get(portType)) {
            if (!this.updateProvidedWSDLAddresses(portType, wsdlFile)) {
                notUpdateWSDLs.add(wsdlFile);
            }
        }
        if (!notUpdateWSDLs.isEmpty()) {
            notChanged.put(portType, notUpdateWSDLs);
        }
    }
    return notChanged;
}
 
Example #7
Source File: WSPortConnector.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an instance of port connector.
 * 
 * @param remoteWsdlUrl
 *            The URL at which the WSDL can be accessed.
 * @param userName
 *            The userName to be used for authentication. <code>null</code>
 *            if no authentication is required.
 * @param password
 *            The password for the user. <code>null</code> if not required.
 * @param host
 *            optional - if specified, this host will be used instead the
 *            one from the wsdl
 * 
 * @throws IOException
 * @throws WSDLException
 */
public WSPortConnector(String remoteWsdlUrl, String userName,
        String password, String host) throws IOException, WSDLException {
    this.userName = userName;
    this.password = password;
    URL url = new URL(remoteWsdlUrl);
    if (requiresUserAuthentication(userName, password)) {
        url = BasicAuthLoader.load(url, userName, password);
    }

    WSDLLocator locator = new BasicAuthWSDLLocator(remoteWsdlUrl, userName,
            password);

    try {
        details = getServiceDetails(locator, host);
    } finally {
        locator.close();
    }
}
 
Example #8
Source File: WSDLToSoapProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void setSoapOperationExtElement(BindingOperation bo) throws ToolException {
    if (extReg == null) {
        extReg = wsdlFactory.newPopulatedExtensionRegistry();
    }
    SoapOperation soapOperation = null;

    try {
        soapOperation = SOAPBindingUtil.createSoapOperation(extReg, isSOAP12());
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
        throw new ToolException(msg, wse);
    }
    soapOperation.setStyle((String)env.get(ToolConstants.CFG_STYLE));
    soapOperation.setSoapActionURI("");
    bo.addExtensibilityElement(soapOperation);
}
 
Example #9
Source File: ApplicationServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the operation service adapter that delegates to the real the
 * port. If a provisioning user is specified, basic authentication will be
 * used.
 * 
 * @param op
 *            the {@link TechnicalProductOperation} to get the action url
 *            from
 * @return the {@link OperationService}
 * @throws IOException
 * @throws ParserConfigurationException
 * @throws WSDLException
 */
protected OperationService getServiceClient(TechnicalProductOperation op)
        throws IOException, WSDLException, ParserConfigurationException {

    TechnicalProduct techProduct = op.getTechnicalProduct();
    String username = techProduct.getProvisioningUsername();
    String password = techProduct.getProvisioningPassword();

    // Get the timeout value for the outgoing WS call from the configuration
    // settings
    Integer wsTimeout = Integer
            .valueOf(cs.getConfigurationSetting(ConfigurationKey.WS_TIMEOUT,
                    Configuration.GLOBAL_CONTEXT).getValue());

    return OperationServiceAdapterFactory.getOperationServiceAdapter(op,
            wsTimeout, username, password);
}
 
Example #10
Source File: SchemaFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Get a new instance of a WSDLFactory. This method
 * returns an instance of the class factoryImplName.
 * Once an instance of a WSDLFactory is obtained, invoke
 * newDefinition(), newWSDLReader(), or newWSDLWriter(), to create
 * the desired instances.
 *
 * @param factoryImplName the fully-qualified class name of the
 * class which provides a concrete implementation of the abstract
 * class WSDLFactory.
 */
public static SchemaFactory newInstance(String factoryImplName) throws WSDLException {
    if (factoryImplName != null) {
        try {
            // get the appropriate class for the loading.
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            Class<?> cl = loader.loadClass(factoryImplName);

            return (SchemaFactory)cl.newInstance();
        } catch (Exception e) {
            /*
             Catches:
             ClassNotFoundException
             InstantiationException
             IllegalAccessException
             */
            throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Problem instantiating factory "
                                                                       + "implementation.", e);
        }
    }
    throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Unable to find name of factory "
                                                               + "implementation.");
}
 
Example #11
Source File: WsdlXmlValidator.java    From iaf with Apache License 2.0 6 votes vote down vote up
@IbisDoc({"the wsdl to read the xsd's from", " "})
public void setWsdl(String wsdl) throws ConfigurationException {
	this.wsdl = wsdl;
	WSDLReader reader  = FACTORY.newWSDLReader();
	reader.setFeature("javax.wsdl.verbose", false);
	reader.setFeature("javax.wsdl.importDocuments", true);
	ClassLoaderWSDLLocator wsdlLocator = new ClassLoaderWSDLLocator(getConfigurationClassLoader(), wsdl);
	URL url = wsdlLocator.getUrl();
	if (wsdlLocator.getUrl() == null) {
		throw new ConfigurationException("Could not find WSDL: " + wsdl);
	}
	try {
		definition = reader.readWSDL(wsdlLocator);
	} catch (WSDLException e) {
		throw new ConfigurationException("WSDLException reading WSDL or import from url: " + url, e);
	}
	if (wsdlLocator.getIOException() != null) {
		throw new ConfigurationException("IOException reading WSDL or import from url: " + url,
				wsdlLocator.getIOException());
	}
}
 
Example #12
Source File: TriggerProcessListener.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a notification on the modification of a subscription to the
 * receiver specified in the trigger definition.
 * 
 * @param process
 *            The current process to be handled.
 * @param facade
 *            Localizer facade to determine translated reason.
 * @throws ParserConfigurationException
 * @throws WSDLException
 * @throws IOException
 */
private void handleModifySubscription(TriggerProcess process,
        LocalizerFacade facade) throws IOException, WSDLException,
        ParserConfigurationException {
    INotificationServiceAdapter serviceClient = getServiceClient(process
            .getTriggerDefinition());
    VOTriggerProcess vo = TriggerProcessAssembler.toVOTriggerProcess(
            process, facade);
    VOSubscription subscription = getParamValue(
            process.getParamValueForName(TriggerProcessParameterName.SUBSCRIPTION),
            VOSubscription.class);
    List<VOParameter> modifiedParameters = ParameterizedTypes
            .list(getParamValue(
                    process.getParamValueForName(TriggerProcessParameterName.PARAMETERS),
                    List.class), VOParameter.class);
    serviceClient.onModifySubscription(VOConverter.convertToApi(vo),
            VOConverter.convertToApi(subscription), VOCollectionConverter
                    .convertList(modifiedParameters,
                            org.oscm.vo.VOParameter.class));

    updateProcessState(process);
}
 
Example #13
Source File: TriggerProcessListener.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a notification on the activation of a product to the receiver
 * specified in the trigger definition.
 * 
 * @param process
 *            The current trigger process to be handled.
 * @param facade
 *            Localizer facade to determine translated reason.
 * @throws ParserConfigurationException
 * @throws WSDLException
 * @throws IOException
 */
private void handleActivateProduct(TriggerProcess process,
        LocalizerFacade facade) throws IOException, WSDLException,
        ParserConfigurationException {
    INotificationServiceAdapter serviceClient = getServiceClient(process
            .getTriggerDefinition());
    VOTriggerProcess vo = TriggerProcessAssembler.toVOTriggerProcess(
            process, facade);
    VOService product = getParamValue(
            process.getParamValueForName(TriggerProcessParameterName.PRODUCT),
            VOService.class);
    serviceClient.onActivateProduct(VOConverter.convertToApi(vo),
            VOConverter.convertToApi(product));

    updateProcessState(process);
}
 
Example #14
Source File: TriggerProcessListener.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a notification on the deactivation of a product to the receiver
 * specified in the trigger definition.
 * 
 * @param process
 *            The current trigger process to be handled.
 * @param facade
 *            Localizer facade to determine translated reason.
 * @throws ParserConfigurationException
 * @throws WSDLException
 * @throws IOException
 */
private void handleDeactivateProduct(TriggerProcess process,
        LocalizerFacade facade) throws IOException, WSDLException,
        ParserConfigurationException {
    INotificationServiceAdapter serviceClient = getServiceClient(process
            .getTriggerDefinition());
    VOTriggerProcess vo = TriggerProcessAssembler.toVOTriggerProcess(
            process, facade);
    VOService product = getParamValue(
            process.getParamValueForName(TriggerProcessParameterName.PRODUCT),
            VOService.class);
    serviceClient.onDeactivateProduct(VOConverter.convertToApi(vo),
            VOConverter.convertToApi(product));

    updateProcessState(process);
}
 
Example #15
Source File: API_051_BindingTemplateWSDLTest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test 
public void testClerkCall() throws ConfigurationException, WSDLException, RemoteException, TransportException, MalformedURLException {
	try {
		tckTModel.saveJoePublisherTmodel(authInfoJoe);
		tckBusiness.saveJoePublisherBusiness(authInfoJoe);
		
		UDDIClerk clerk = new UDDIClient("META-INF/uddi.xml").getClerk("joe");
		clerk.registerWsdls();
		
		
		String portTypeName = "StockQuotePortType";
		String namespace    = "http://example.com/stockquote/";
		FindTModel findTModelForPortType = WSDL2UDDI.createFindPortTypeTModelForPortType(portTypeName, namespace);
		System.out.println(new PrintUDDI<FindTModel>().print(findTModelForPortType));
		
		clerk.unRegisterWsdls();
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail();
	} finally {
		tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
		tckTModel.deleteJoePublisherTmodel(authInfoJoe);
	}
}
 
Example #16
Source File: CompressAndEncodeTool.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
/**
    * Gets WSDL as ZLIB-compressed and Base64-encoded String.
    * Use ZipStream -> InflaterStream -> Base64Stream to read.
    * @return WSDL as String object. Or null in case errors/not possible to create object.
    * @throws WSDLException 
    * @throws IOException 
    */
public static String compressAndEncode(Definition definition) throws IOException, WSDLException {
   	ByteArrayOutputStream wsdlOs = new ByteArrayOutputStream();
       OutputStream os = compressAndEncodeStream(wsdlOs);
       ZipOutputStream zipOs = new ZipOutputStream(os);
       try {
       	ZipEntry zipEntry = new ZipEntry("main.wsdl");
		zipOs.putNextEntry(zipEntry);
           WSDLFactory.newInstance().newWSDLWriter().writeWSDL(definition, zipOs);
           appendImportDifinitions(definition, zipOs);
	} finally {
           if (null != zipOs) {
               zipOs.close();
           }
       }
       return wsdlOs.toString();
   }
 
Example #17
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
/** Generates a corba:operation in the corba:binding container within a wsdl:binding.
 *
 * Only one (or none) corba parameter and only one (or none) corba return parameter are supported.
 *
 * @param op is the wsdl operation to bind.
 * @param param is the corba parameter, none if null.
 * @param arg is the corba return parameter, none if null.
 * @return the generated corba:operation.
 */
private OperationType generateCorbaOperation(Operation op, ParamType param, ArgType arg) {
    OperationType operation = null;
    try {
        operation = (OperationType)extReg.createExtension(BindingOperation.class,
                                                          CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException ex) {
        throw new RuntimeException(ex);
    }
    operation.setName(op.getName());

    if (param != null) {
        operation.getParam().add(param);
    }

    if (arg != null) {
        operation.setReturn(arg);
    }

    return operation;
}
 
Example #18
Source File: SoapTransportFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void createSoapExtensors(Bus bus, EndpointInfo ei, SoapBindingInfo bi, boolean isSoap12) {
    try {

        String address = ei.getAddress();
        if (address == null) {
            address = "http://localhost:9090";
        }

        ExtensionRegistry registry = bus.getExtension(WSDLManager.class).getExtensionRegistry();
        SoapAddress soapAddress = SOAPBindingUtil.createSoapAddress(registry, isSoap12);
        soapAddress.setLocationURI(address);

        ei.addExtensor(soapAddress);

    } catch (WSDLException e) {
        e.printStackTrace();
    }
}
 
Example #19
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Definition initWsdl( String serviceName, String filename ) {
	try {
		wsdlFactory = WSDLFactory.newInstance();
		localDef = wsdlFactory.newDefinition();
		extensionRegistry = wsdlFactory.newPopulatedExtensionRegistry();
		if( serviceName != null ) {
			QName servDefQN = new QName( serviceName );
			localDef.setQName( servDefQN );
		}
		localDef.addNamespace( NameSpacesEnum.WSDL.getNameSpacePrefix(), NameSpacesEnum.WSDL.getNameSpaceURI() );
		localDef.addNamespace( NameSpacesEnum.SOAP.getNameSpacePrefix(), NameSpacesEnum.SOAP.getNameSpaceURI() );
		localDef.addNamespace( "tns", tns );
		localDef.addNamespace( NameSpacesEnum.XML_SCH.getNameSpacePrefix(),
			NameSpacesEnum.XML_SCH.getNameSpaceURI() );
		localDef.setTargetNamespace( tns );
		localDef.addNamespace( "xsd1", tnsSchema );
	} catch( WSDLException ex ) {
		Logger.getLogger( WSDLDocCreator.class.getName() ).log( Level.SEVERE, null, ex );
	}

	return localDef;
}
 
Example #20
Source File: BPEL2UDDITest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test
public void testHelloWorld_UDDIBindingModel() throws WSDLException, JAXBException, Exception {

	// Reading the WSDL
	Definition wsdlDefinition = rw.readWSDL("bpel/HelloWorld.wsdl");
    @SuppressWarnings("unchecked")
	Map<QName,Binding> bindings = (Map<QName,Binding>) wsdlDefinition.getAllBindings();
    Set<TModel> bindingTModels = bpel2UDDI.createWSDLBindingTModels(wsdlDefinition.getDocumentBaseURI(), bindings);
    
	for (TModel tModel : bindingTModels) {
		System.out.println("***** UDDI Binding TModel: " + tModel.getName().getValue());
                       if (serialize)
		System.out.println(pTModel.print(tModel));
	}
	Assert.assertEquals(1,bindingTModels.size());
}
 
Example #21
Source File: WSDLGetUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Create a wsdl Definition object from the endpoint information and register
 * it in the local data structure for future reference.
 *
 * @param bus CXF's hub for access to internal constructs
 * @param mp  a map of known wsdl Definition objects
 * @param message
 * @param smp a map of known xsd SchemaReference objects
 * @param base the request URL
 * @param endpointInfo information for a web service 'port' inside of a service
 * @throws WSDLException
 */
protected void updateWSDLKeyDefinition(Bus bus,
                                       Map<String, Definition> mp,
                                       Message message,
                                       Map<String, SchemaReference> smp,
                                       String base,
                                       EndpointInfo endpointInfo) throws WSDLException {
    if (!mp.containsKey("")) {
        ServiceWSDLBuilder builder =
            new ServiceWSDLBuilder(bus, endpointInfo.getService());

        builder.setUseSchemaImports(
            MessageUtils.getContextualBoolean(message, WSDL_CREATE_IMPORTS, false));

        // base file name is ignored if createSchemaImports == false!
        builder.setBaseFileName(endpointInfo.getService().getName().getLocalPart());

        Definition def = builder.build(new HashMap<String, SchemaInfo>());

        mp.put("", def);
        updateDefinition(bus, def, mp, smp, base, "", "");
    }

}
 
Example #22
Source File: TriggerProcessListener.java    From development with Apache License 2.0 6 votes vote down vote up
private void handleSubscriptionTermination(TriggerProcess process,
        LocalizerFacade facade) throws IOException, WSDLException,
        ParserConfigurationException {
    INotificationServiceAdapter serviceClient = getServiceClient(process
            .getTriggerDefinition());
    VOTriggerProcess vo = TriggerProcessAssembler.toVOTriggerProcess(
            process, facade);
    String subscriptionId = getParamValue(
            process.getParamValueForName(TriggerProcessParameterName.SUBSCRIPTION),
            String.class);
    Invariants.assertNotNull(subscriptionId,
            "mandatory parameter 'subscriptionId' not set");

    VONotificationBuilder builder = new VONotificationBuilder();
    builder.addParameter(VOProperty.SUBSCRIPTION_SUBSCRIPTION_ID,
            subscriptionId);
    VONotification notification = builder.build();

    serviceClient.onSubscriptionTermination(VOConverter.convertToApi(vo),
            notification);
    updateProcessState(process);
}
 
Example #23
Source File: XTeeSoapProvider.java    From j-road with Apache License 2.0 6 votes vote down vote up
@Override
protected void populatePort(Definition definition, Port port) throws WSDLException {
  super.populatePort(definition, port);
  ExtensionRegistry extensionRegistry = definition.getExtensionRegistry();
  extensionRegistry.mapExtensionTypes(Port.class,
                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                "address",
                                                XTeeWsdlDefinition.XROAD_PREFIX),
                                      UnknownExtensibilityElement.class);
  UnknownExtensibilityElement element =
      (UnknownExtensibilityElement) extensionRegistry.createExtension(Port.class,
                                                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                                                "address",
                                                                                XTeeWsdlDefinition.XROAD_NAMESPACE));
  Document doc;
  try {
    doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  } catch (ParserConfigurationException e) {
    throw new RuntimeException(e);
  }
  Element xRoadAddr = doc.createElementNS(XTeeWsdlDefinition.XROAD_NAMESPACE, "address");
  xRoadAddr.setPrefix(XTeeWsdlDefinition.XROAD_PREFIX);
  xRoadAddr.setAttribute("producer", xRoadDatabase);
  element.setElement(xRoadAddr);
  port.addExtensibilityElement(element);
}
 
Example #24
Source File: XTeeSoapProvider.java    From j-road with Apache License 2.0 5 votes vote down vote up
@Override
protected void populateBindingOutput(Definition definition, BindingOutput bindingOutput, Output output)
    throws WSDLException {
  for (SOAPHeader header : makeHeaders(definition)) {
    bindingOutput.addExtensibilityElement(header);
  }
  super.populateBindingOutput(definition, bindingOutput, output);
}
 
Example #25
Source File: ODEEndpointUpdater.java    From container with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the addresses inside the given WSDL file by using endpoints inside the endpoint db
 *
 * @param portType a QName which represents a PortType
 * @param wsdl     a File which is from type .wsdl
 * @throws WSDLException if the WSDL parser couldn't parse
 */
private boolean updateInvokedWSDLAddresses(final QName portType, final File wsdl) throws WSDLException {
    boolean changed = false;
    LOG.debug("Trying to change WSDL file {} ", wsdl.getName());
    final Definition wsdlDef = getWsdlReader().readWSDL(wsdl.getAbsolutePath());
    for (final Object o : wsdlDef.getAllServices().values()) {
        // get the services
        final Service service = (Service) o;
        for (final Object obj : service.getPorts().values()) {
            // get the ports of the service
            final Port port = (Port) obj;
            if (port.getBinding().getPortType().getQName().equals(portType)) {
                // get binding and its porttype
                // get the extensible elements out of wsdl and check them
                // with endpointservice

                LOG.debug("Found matching porttype for WSDL file {} ", wsdl.getName());
                if (changePortAddressWithEndpointDB(port)) {
                    // changing -> success
                    changed = true;
                }
            }
        }
    }
    try {
        // if we changed something, rewrite the the wsdl
        if (changed) {
            this.factory.newWSDLWriter().writeWSDL(wsdlDef, new FileOutputStream(wsdl));
        }
    } catch (final FileNotFoundException e) {
        LOG.debug("Couldn't locate wsdl file", e);
        changed = false;
    }
    return changed;
}
 
Example #26
Source File: WSDLServiceFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public WSDLServiceFactory(Bus b, String url, QName sn) {
    setBus(b);
    wsdlUrl = url;
    try {
        // use wsdl manager to parse wsdl or get cached definition
        definition = getBus().getExtension(WSDLManager.class).getDefinition(url);
    } catch (WSDLException ex) {
        throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex);
    }

    serviceName = sn;
}
 
Example #27
Source File: Wsdl11AttachmentPolicyProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void oneTimeSetUp() throws Exception {

    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    WSDLManager manager = new WSDLManagerImpl();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(dfm).anyTimes();
    EasyMock.expect(dfm.getDestinationFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes();
    EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    control.replay();

    int n = 19;
    services = new ServiceInfo[n];
    endpoints = new EndpointInfo[n];
    for (int i = 0; i < n; i++) {
        String resourceName = "/attachment/wsdl11/test" + i + ".wsdl";
        URL url = Wsdl11AttachmentPolicyProviderTest.class.getResource(resourceName);
        try {
            services[i] = builder.buildServices(manager.getDefinition(url.toString())).get(0);
        } catch (WSDLException ex) {
            ex.printStackTrace();
            fail("Failed to build service from resource " + resourceName);
        }
        assertNotNull(services[i]);
        endpoints[i] = services[i].getEndpoints().iterator().next();
        assertNotNull(endpoints[i]);
    }

    control.verify();

}
 
Example #28
Source File: WsdlXmlValidatorTest.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Test(expected = XmlValidatorException.class)
public void wsdlTibcoFailEnvelop() throws IOException, PipeRunException, SAXException, WSDLException, ConfigurationException, XmlValidatorException {
    WsdlXmlValidator val = new WsdlXmlValidator();
    val.setWsdl(TIBCO);
    val.setThrowException(true);
    val.registerForward(new PipeForward("success", null));
    val.configure();
    val.validate("<Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
            "  <BodyERROR>\n" +
            "    <MessageHeader xmlns=\"http://www.ing.com/CSP/XSD/General/Message_2\">\n" +
            "      <From>\n" +
            "        <Id>Ibis4Toegang</Id>\n" +
            "      </From>\n" +
            "      <HeaderFields>\n" +
            "        <ConversationId/>\n" +
            "        <MessageId>WPNLD8921975_0a4ac029-7747a1ed_12da7d4b033_-7ff3</MessageId>\n" +
            "        <ExternalRefToMessageId/>\n" +
            "        <Timestamp>2001-12-17T09:30:47</Timestamp>\n" +
            "      </HeaderFields>\n" +
            "    </MessageHeader>\n" +
            "    <Request xmlns=\"http://www.ing.com/nl/banking/coe/xsd/bankingcustomer_generate_01/getpartybasicdatabanking_01\">\n" +
            "      <BankSparen xmlns=\"http://www.ing.com/bis/xsd/nl/banking/bankingcustomer_generate_01_getpartybasicdatabanking_request_01\">\n" +
            "        <PRD>\n" +
            "          <KLT>\n" +
            "            <KLT_NA_RELNUM>181373377001</KLT_NA_RELNUM>\n" +
            "          </KLT>\n" +
            "        </PRD>\n" +
            "      </BankSparen>\n" +
            "    </Request>\n" +
            "  </BodyERROR>\n" +
            "</Envelope>\n" +
            "", session);
}
 
Example #29
Source File: UDDIServiceCache.java    From juddi with Apache License 2.0 5 votes vote down vote up
public UDDIServiceCache(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties) throws DatatypeConfigurationException, MalformedURLException, RemoteException, ConfigurationException, WSDLException, TransportException, Exception {
	super();
	this.clerk = clerk;
	this.urlLocalizer = urlLocalizer;
	
	Properties properties2 = clerk.getUDDINode().getProperties();
	if (properties2!=null) {
		properties2.putAll(properties);
	} else {
		properties2 = properties;
	}
	this.properties = properties2;
}
 
Example #30
Source File: TestUtilities.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Return a WSDL definition model for a server.
 *
 * @param server the server.
 * @return the definition.
 * @throws WSDLException
 */
public Definition getWSDLDefinition(Server server) throws WSDLException {
    Service service = server.getEndpoint().getService();

    ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0));
    wsdlBuilder.setUseSchemaImports(false);
    return wsdlBuilder.build();
}