|
Apache CXF example source code file (PolicyAnnotationTest.java)
The Apache CXF PolicyAnnotationTest.java source code/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.cxf.ws.policy; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.jws.WebService; import javax.wsdl.Definition; import javax.wsdl.xml.WSDLWriter; import javax.xml.xpath.XPathConstants; import org.w3c.dom.Element; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.annotations.Policies; import org.apache.cxf.annotations.Policy; import org.apache.cxf.common.WSDLConstants; import org.apache.cxf.endpoint.Server; import org.apache.cxf.helpers.XPathUtils; import org.apache.cxf.jaxws.JaxWsServerFactoryBean; import org.apache.cxf.transport.local.LocalTransportFactory; import org.apache.cxf.wsdl.WSDLManager; import org.apache.cxf.wsdl11.ServiceWSDLBuilder; import org.junit.Assert; /** * */ public class PolicyAnnotationTest extends Assert { @org.junit.Test public void testAnnotations() throws Exception { Bus bus = BusFactory.getDefaultBus(); JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setBus(bus); factory.setServiceBean(new TestImpl()); factory.setStart(false); List<String> tp = Arrays.asList( "http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat"); LocalTransportFactory f = new LocalTransportFactory(); f.getUriPrefixes().add("http"); f.setTransportIds(tp); f.setBus(bus); f.register(); Server s = factory.create(); try { ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService() .getServiceInfos()); Definition def = builder.build(); WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class) .getWSDLFactory().newWSDLWriter(); def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry()); Element wsdl = wsdlWriter.getDocument(def).getDocumentElement(); Map<String, String> ns = new HashMap Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF PolicyAnnotationTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.