本文整理汇总了Java中javax.wsdl.Definition类的典型用法代码示例。如果您正苦于以下问题:Java Definition类的具体用法?Java Definition怎么用?Java Definition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Definition类属于javax.wsdl包,在下文中一共展示了Definition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPortTypeOperations
import javax.wsdl.Definition; //导入依赖的package包/类
/**
* 参考SoapMessageBuilder.SoapMessageBuilder(URL wsdlUrl)方法
* 获取portType中的所有operation
*
* @param wsdlUrl
* @return
*/
private static List<Operation> getPortTypeOperations(String wsdlUrl) {
List<Operation> operationList = new ArrayList();
try {
WSDLReader reader = new WSDLReaderImpl();
reader.setFeature("javax.wsdl.verbose", false);
Definition definition = reader.readWSDL(wsdlUrl.toString());
Map<String, PortTypeImpl> defMap = definition.getAllPortTypes();
Collection<PortTypeImpl> collection = defMap.values();
for (PortTypeImpl portType : collection) {
operationList.addAll(portType.getOperations());
}
} catch (WSDLException e) {
System.out.println("get wsdl operation fail.");
e.printStackTrace();
}
return operationList;
}
示例2: addWsdlPortTypeOperation
import javax.wsdl.Definition; //导入依赖的package包/类
private static void addWsdlPortTypeOperation(Definition definition, QName portTypeQName, String operationName, String operationComment, QName inputQName, QName ouptutQName) {
Message inputMessage = definition.createMessage();
inputMessage.setQName(inputQName);
Input input = definition.createInput();
input.setMessage(inputMessage);
Message outpuMessage = definition.createMessage();
outpuMessage.setQName(ouptutQName);
Output output = definition.createOutput();
output.setMessage(outpuMessage);
Operation operation = definition.createOperation();
operation.setName(operationName);
operation.setInput(input);
operation.setOutput(output);
operation.setUndefined(false);
addWsdLDocumentation(definition, operation, operationComment);
PortType portType = definition.getPortType(portTypeQName);
portType.addOperation(operation);
}
示例3: validateVersion
import javax.wsdl.Definition; //导入依赖的package包/类
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);
}
}
示例4: testWsdl
import javax.wsdl.Definition; //导入依赖的package包/类
@Test
@RunAsClient
public void testWsdl() throws Exception
{
URL wsdlURL = new URL(baseURL + "/jaxws-jbws2183/TestServiceImpl?wsdl");
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
assertNotNull(wsdlDefinition);
for (Iterator<?> it = wsdlDefinition.getAllBindings().values().iterator(); it.hasNext(); )
{
List<?> extElements = ((Binding)it.next()).getExtensibilityElements();
boolean found = false;
for (int i = 0; i < extElements.size(); i++)
{
ExtensibilityElement extElement = (ExtensibilityElement)extElements.get(i);
if (extElement instanceof SOAP12Binding)
found = true;
else if (extElement instanceof SOAPBinding)
fail("SOAP 1.1 Binding found!");
}
assertTrue("SOAP 1.2 Binding not found!",found);
}
}
示例5: test
import javax.wsdl.Definition; //导入依赖的package包/类
@Test
@RunAsClient
public void test() throws Exception
{
File destDir = new File(TEST_DIR, "wsprovide" + FS + "java");
String absOutput = destDir.getAbsolutePath();
String command = JBOSS_HOME + FS + "bin" + FS + "wsprovide" + EXT + " -k -w -o " + absOutput + " --classpath " + CLASSES_DIR + " " + ENDPOINT_CLASS;
Map<String, String> env = new HashMap<>();
env.put("JAVA_OPTS", System.getProperty("additionalJvmArgs"));
executeCommand(command, null, "wsprovide", env);
URL wsdlURL = new File(destDir, "JBWS2528EndpointService.wsdl").toURI().toURL();
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
Definition wsdlDefinition = wsdlReader.readWSDL(wsdlURL.toString());
PortType portType = wsdlDefinition.getPortType(new QName("http://jbws2528.jaxws.ws.test.jboss.org/", "JBWS2528Endpoint"));
Operation op = (Operation)portType.getOperations().get(0);
@SuppressWarnings("unchecked")
List<String> parOrder = op.getParameterOrdering();
assertEquals("id", parOrder.get(0));
assertEquals("Name", parOrder.get(1));
assertEquals("Employee", parOrder.get(2));
}
示例6: addWsdlOperation
import javax.wsdl.Definition; //导入依赖的package包/类
private static void addWsdlOperation(Definition definition, RequestableObject requestable, List<QName> qnames) {
String targetNamespace = definition.getTargetNamespace();
String projectName = requestable.getProject().getName();
String operationName = requestable.getXsdTypePrefix() + requestable.getName();
String operationComment = requestable.getComment();
// Adds messages
QName requestQName = new QName(targetNamespace, operationName + "Request");
QName partElementRequestQName = new QName(targetNamespace, operationName);
addWsdlMessage(definition, requestQName, partElementRequestQName);
addPartElementQName(qnames, partElementRequestQName);
QName responseQName = new QName(targetNamespace, operationName + "Response");
QName partElementResponseQName = new QName(targetNamespace, operationName + "Response");
addWsdlMessage(definition, responseQName, partElementResponseQName);
addPartElementQName(qnames, partElementResponseQName);
// Adds portType operation
QName portTypeQName = new QName(targetNamespace, projectName + "PortType");
addWsdlPortTypeOperation(definition, portTypeQName, operationName, operationComment, requestQName, responseQName);
// Adds binding operation
QName bindingQName = new QName(targetNamespace, projectName + "SOAPBinding");
addWsdlBindingOperation(definition, bindingQName, projectName, operationName, operationComment);
}
示例7: addWsdlBindingOperation
import javax.wsdl.Definition; //导入依赖的package包/类
private static void addWsdlBindingOperation(Definition definition, QName bindingQName, String projectName, String operationName, String operationComment) {
SOAPBodyImpl soapInputBody = new SOAPBodyImpl();
soapInputBody.setUse("literal");
BindingInput bindingInput = definition.createBindingInput();
bindingInput.addExtensibilityElement(soapInputBody);
SOAPBodyImpl soapOutputBody = new SOAPBodyImpl();
soapOutputBody.setUse("literal");
BindingOutput bindingOutput = definition.createBindingOutput();
bindingOutput.addExtensibilityElement(soapOutputBody);
SOAPOperationImpl soapOperation = new SOAPOperationImpl();
soapOperation.setSoapActionURI(projectName + "?" + operationName);
BindingOperation bindingOperation = definition.createBindingOperation();
bindingOperation.setName(operationName);
bindingOperation.addExtensibilityElement(soapOperation);
bindingOperation.setBindingInput(bindingInput);
bindingOperation.setBindingOutput(bindingOutput);
addWsdLDocumentation(definition, bindingOperation, operationComment);
Binding binding = definition.getBinding(bindingQName);
binding.addBindingOperation(bindingOperation);
}
示例8: addWsdLDocumentation
import javax.wsdl.Definition; //导入依赖的package包/类
private static void addWsdLDocumentation(Definition definition, WSDLElement wsdlElement, String documentation) {
if (documentation.equals(""))
return;
try {
Document doc = new WSDLWriterImpl().getDocument(definition);
Element element = doc.createElementNS("http://schemas.xmlsoap.org/wsdl/","documentation");
element.setPrefix("wsdl");
String cdataValue = documentation;
cdataValue = cdataValue.replaceAll("<!\\[CDATA\\[", "<!\\[CDATA\\[");
cdataValue = cdataValue.replaceAll("\\]\\]>", "\\]\\]>");
element.appendChild(doc.createCDATASection(cdataValue));
wsdlElement.setDocumentationElement(element);
} catch (WSDLException e) {
e.printStackTrace();
}
}
示例9: importServicesAndOperations
import javax.wsdl.Definition; //导入依赖的package包/类
/**
* Imports services and operations from the WSDL definition
*/
protected void importServicesAndOperations(Definition definition) {
for (Object serviceObject : definition.getServices().values()) {
Service service = (Service) serviceObject;
WSService wsService = this.importService(service);
this.wsServices.put(this.namespace + wsService.getName(), wsService);
Port port = (Port) service.getPorts().values().iterator().next();
for (Object bindOperationObject : port.getBinding().getBindingOperations()) {
BindingOperation bindOperation = (BindingOperation) bindOperationObject;
WSOperation operation = this.processOperation(bindOperation.getOperation(), wsService);
wsService.addOperation(operation);
this.wsOperations.put(this.namespace + operation.getName(), operation);
}
}
}
示例10: getServiceName
import javax.wsdl.Definition; //导入依赖的package包/类
public QName getServiceName() {
if (serviceName == null && serviceNameString != null) {
serviceName = QName.valueOf(resolvePropertyPlaceholders(serviceNameString));
}
//if not specify the service name and if the wsdlUrl is available,
//parse the wsdl to see if only one service in it, if so set the only service
//from wsdl to avoid ambiguity
if (serviceName == null && getWsdlURL() != null) {
// use wsdl manager to parse wsdl or get cached
// definition
try {
Definition definition = getBus().getExtension(WSDLManager.class)
.getDefinition(getWsdlURL());
if (definition.getServices().size() == 1) {
serviceName = (QName) definition.getServices().keySet()
.iterator().next();
}
} catch (WSDLException e) {
throw new RuntimeException(e);
}
}
return serviceName;
}
示例11: parseWSDLTypes
import javax.wsdl.Definition; //导入依赖的package包/类
private void parseWSDLTypes( XSOMParser schemaParser )
throws IOException
{
Definition definition = getWSDLDefinition();
if ( definition != null ) {
Types types = definition.getTypes();
if ( types != null ) {
List<ExtensibilityElement> list = types.getExtensibilityElements();
for( ExtensibilityElement element : list ) {
if ( element instanceof SchemaImpl ) {
Element schemaElement = ((SchemaImpl) element).getElement();
Map<String, String> namespaces = definition.getNamespaces();
for( Entry<String, String> entry : namespaces.entrySet() ) {
if ( entry.getKey().equals( "xmlns" ) || entry.getKey().trim().isEmpty() ) {
continue;
}
if ( schemaElement.getAttribute( "xmlns:" + entry.getKey() ).isEmpty() ) {
schemaElement.setAttribute( "xmlns:" + entry.getKey(), entry.getValue() );
}
}
parseSchemaElement( definition, schemaElement, schemaParser );
}
}
}
}
}
示例12: getWSDLPort
import javax.wsdl.Definition; //导入依赖的package包/类
private Port getWSDLPort()
throws IOException
{
Port port = wsdlPort;
if ( port == null && hasParameter( "wsdl" ) && getParameterFirstValue( "wsdl" ).hasChildren( "port" ) ) {
String portName = getParameterFirstValue( "wsdl" ).getFirstChild( "port" ).strValue();
Definition definition = getWSDLDefinition();
if ( definition != null ) {
Map<QName, Service> services = definition.getServices();
Iterator<Entry<QName, Service>> it = services.entrySet().iterator();
while( port == null && it.hasNext() ) {
port = it.next().getValue().getPort( portName );
}
}
if ( port != null ) {
wsdlPort = port;
}
}
return port;
}
示例13: addOWOperation2PT
import javax.wsdl.Definition; //导入依赖的package包/类
private Operation addOWOperation2PT(Definition def, PortType pt, OneWayOperationDeclaration op) {
Operation wsdlOp = def.createOperation();
wsdlOp.setName(op.id());
wsdlOp.setStyle(OperationType.ONE_WAY);
wsdlOp.setUndefined(false);
Input in = def.createInput();
Message msg_req = addRequestMessage(localDef, op);
msg_req.setUndefined(false);
in.setMessage(msg_req);
wsdlOp.setInput(in);
wsdlOp.setUndefined(false);
pt.addOperation(wsdlOp);
return wsdlOp;
}
示例14: createBindingSOAP
import javax.wsdl.Definition; //导入依赖的package包/类
private Binding createBindingSOAP(Definition def, PortType pt, String bindingName) {
Binding bind = def.getBinding(new QName(bindingName));
if (bind == null) {
bind = def.createBinding();
bind.setQName(new QName(tns, bindingName));
}
bind.setPortType(pt);
bind.setUndefined(false);
try {
SOAPBinding soapBinding = (SOAPBinding) extensionRegistry.createExtension(Binding.class, new QName(NameSpacesEnum.SOAP.getNameSpaceURI(), "binding"));
soapBinding.setTransportURI(NameSpacesEnum.SOAPoverHTTP.getNameSpaceURI());
soapBinding.setStyle("document");
bind.addExtensibilityElement(soapBinding);
} catch (WSDLException ex) {
System.out.println((ex.getStackTrace()));
}
def.addBinding(bind);
return bind;
}
示例15: createService
import javax.wsdl.Definition; //导入依赖的package包/类
public Service createService(Definition localdef, String serviceName, Binding bind, String mySOAPAddress) {
Port p = localDef.createPort();
p.setName(serviceName + "Port");
try {
SOAPAddress soapAddress = (SOAPAddress) extensionRegistry.createExtension(Port.class, new QName(NameSpacesEnum.SOAP.getNameSpaceURI(), "address"));
soapAddress.setLocationURI(mySOAPAddress);
p.addExtensibilityElement(soapAddress);
} catch (WSDLException ex) {
ex.printStackTrace();
}
p.setBinding(bind);
Service s = new ServiceImpl();
QName serviceQName = new QName(serviceName);
s.setQName(serviceQName);
s.addPort(p);
localDef.addService(s);
return s;
}