use of javax.wsdl.Service in project cxf by apache.
the class JavaToProcessorTest method testDocLitUseClassPathFlag.
@Test
public void testDocLitUseClassPathFlag() throws Exception {
File classFile = new java.io.File(output.getCanonicalPath() + "/classes");
classFile.mkdir();
System.setProperty("java.class.path", getClassPath() + classFile.getCanonicalPath() + File.separatorChar);
env.put(ToolConstants.CFG_COMPILE, ToolConstants.CFG_COMPILE);
env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
env.put(ToolConstants.CFG_PACKAGENAME, "org.apache.cxf.classpath");
env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/hello_world_doc_lit.wsdl"));
JAXWSContainer w2jProcessor = new JAXWSContainer(null);
w2jProcessor.setContext(env);
w2jProcessor.execute();
String tns = "http://apache.org/sepecifiedTns";
String serviceName = "cxfService";
String portName = "cxfPort";
System.setProperty("java.class.path", "");
// test flag
String[] args = new String[] { "-o", "java2wsdl.wsdl", "-cp", classFile.getCanonicalPath(), "-t", tns, "-servicename", serviceName, "-portname", portName, "-soap12", "-d", output.getPath(), "-wsdl", "org.apache.cxf.classpath.Greeter" };
JavaToWS.main(args);
File wsdlFile = new File(output, "java2wsdl.wsdl");
assertTrue("Generate Wsdl Fail", wsdlFile.exists());
Definition def = wsdlHelper.getDefinition(wsdlFile);
Service wsdlService = def.getService(new QName(tns, serviceName));
assertNotNull("Generate WSDL Service Error", wsdlService);
Port wsdlPort = wsdlService.getPort(portName);
assertNotNull("Generate service port error ", wsdlPort);
}
use of javax.wsdl.Service in project cxf by apache.
the class JavaToProcessorTest method testSimpleClass.
@Test
public void testSimpleClass() throws Exception {
env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/doc_wrapped_bare.wsdl");
env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.simple.Hello");
processor.setEnvironment(env);
processor.process();
File wsdlFile = new File(output, "doc_wrapped_bare.wsdl");
assertTrue("Fail to generate wsdl file: " + wsdlFile.toString(), wsdlFile.exists());
String tns = "http://simple.fortest.tools.cxf.apache.org/";
Definition def = wsdlHelper.getDefinition(wsdlFile);
assertNotNull(def);
Service wsdlService = def.getService(new QName(tns, "Hello"));
assertNotNull("Generate WSDL Service Error", wsdlService);
}
use of javax.wsdl.Service in project carbon-business-process by wso2.
the class ProcessConfigurationImpl method initPartnerLinks.
/**
* Initialize partner link details of the BPEL process. Details about partner link's service and
* port is in the deploy.xml file. This can be used to initialize partner links information in
* registry. After that we can co-relate this partner links with carbon endpoints. This will
* help us to dynamically configure endpoint properties like security, RM.
*/
private void initPartnerLinks() {
if (processInfo.getInvokeList() != null) {
for (TInvoke invoke : processInfo.getInvokeList()) {
String plinkName = invoke.getPartnerLink();
TService service = invoke.getService();
// configure this value
if (service == null) {
continue;
}
if (log.isDebugEnabled()) {
log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" + plinkName + " -->" + service);
}
QName serviceName = service.getName();
/* Validating configuration with package content before putting partner role endpoints to map */
Definition wsdlDef = getDefinitionForService(serviceName);
if (wsdlDef == null) {
String errMsg = "Cannot find WSDL definition for invoke service " + serviceName + ". Required resources not found in the BPEL package " + du.getName() + ".";
log.error(errMsg);
throw new ContextException(errMsg);
}
Service serviceDef = wsdlDef.getService(serviceName);
if (serviceDef.getPort(service.getPort()) == null) {
String errMsg = "Cannot find port for invoking service for the given name " + serviceName + ". Error in deploy.xml.";
log.error(errMsg);
throw new ContextException(errMsg);
}
partnerRoleInitialValues.put(plinkName, new Endpoint(service.getName(), service.getPort()));
// TODO add proper variable names
{
OFailureHandling g = null;
if (invoke.isSetFailureHandling()) {
FailureHandlingDocument.FailureHandling fh = invoke.getFailureHandling();
g = new OFailureHandling();
if (fh.isSetFaultOnFailure()) {
g.faultOnFailure = fh.getFaultOnFailure();
}
if (fh.isSetRetryDelay()) {
g.retryDelay = fh.getRetryDelay();
}
if (fh.isSetRetryFor()) {
g.retryFor = fh.getRetryFor();
}
}
PartnerRoleConfig c = new PartnerRoleConfig(g, invoke.getUsePeer2Peer());
if (log.isDebugEnabled()) {
log.debug("PartnerRoleConfig for " + plinkName + " " + c.failureHandling + " usePeer2Peer: " + c.usePeer2Peer);
}
partnerRoleConfigurations.put(plinkName, c);
}
}
}
if (processInfo.getProvideList() != null) {
for (TProvide proivde : processInfo.getProvideList()) {
String plinkName = proivde.getPartnerLink();
TService service = proivde.getService();
if (proivde.getCorrelationFilter() != null) {
if (B4P_NAMESPACE.equals(proivde.getCorrelationFilter().getNamespaceURI())) {
isB4PTaskIncluded = true;
}
}
/* NOTE:Service cannot be null for provider partner link*/
if (service == null) {
String errorMsg = "Error in <provide> element for process " + processInfo.getName() + ";partnerlink" + plinkName + "did not identify an endpoint";
log.error(errorMsg);
throw new ContextException(errorMsg);
}
if (log.isDebugEnabled()) {
log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
}
QName serviceName = service.getName();
/* Validating configuration with package content before putting myRole endpoints to map */
Definition wsdlDef = getDefinitionForService(serviceName);
if (wsdlDef == null) {
String errMsg = "Cannot find WSDL definition for provide service " + serviceName + ". Required resources not found in the BPEL " + "package " + du.getName() + ".";
log.error(errMsg);
throw new ContextException(errMsg);
}
Service serviceDef = wsdlDef.getService(serviceName);
if (serviceDef.getPort(service.getPort()) == null) {
String errMsg = "Cannot find provide port in the given service " + serviceName + ". Error in deploy.xml.";
log.error(errMsg);
throw new ContextException(errMsg);
}
myRoleEndpoints.put(plinkName, new Endpoint(service.getName(), service.getPort()));
if (proivde.isSetEnableSharing()) {
sharedServices.add(service.getName());
}
}
}
}
use of javax.wsdl.Service in project carbon-business-process by wso2.
the class PartnerService method inferBindingInformation.
private void inferBindingInformation() {
Service serviceDef = wsdlDefinition.getService(serviceName);
if (serviceDef == null) {
throw new NullPointerException(Messages.msgServiceDefinitionNotFound(serviceName.getLocalPart()));
}
Port port = serviceDef.getPort(portName);
if (port == null) {
throw new NullPointerException(Messages.msgServicePortNotFound(serviceName.getLocalPart(), portName));
}
binding = port.getBinding();
if (binding == null) {
throw new NullPointerException(Messages.msgBindingNotFound(serviceName.getLocalPart(), portName));
}
}
use of javax.wsdl.Service in project ofbiz-framework by apache.
the class ModelService method getWSDL.
public void getWSDL(Definition def, String locationURI) throws WSDLException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
Document document = null;
try {
builder = factory.newDocumentBuilder();
document = builder.newDocument();
} catch (Exception e) {
throw new WSDLException("can not create WSDL", module);
}
def.setTypes(this.getTypes(document, def));
// set the IN parameters
Input input = def.createInput();
Set<String> inParam = this.getInParamNames();
Message inMessage = def.createMessage();
inMessage.setQName(new QName(TNS, this.name + "Request"));
inMessage.setUndefined(false);
Part parametersPart = def.createPart();
parametersPart.setName("map-Map");
parametersPart.setTypeName(new QName(TNS, "map-Map"));
inMessage.addPart(parametersPart);
Element documentation = document.createElement("wsdl:documentation");
for (String paramName : inParam) {
ModelParam param = this.getParam(paramName);
if (!param.internal) {
Part part = param.getWSDLPart(def);
Element attribute = document.createElement("attribute");
attribute.setAttribute("name", paramName);
attribute.setAttribute("type", part.getTypeName().getLocalPart());
attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
attribute.setAttribute("java-class", param.type);
attribute.setAttribute("optional", Boolean.toString(param.optional));
documentation.appendChild(attribute);
}
}
Element usernameAttr = document.createElement("attribute");
usernameAttr.setAttribute("name", "login.username");
usernameAttr.setAttribute("type", "std-String");
usernameAttr.setAttribute("namespace", TNS);
usernameAttr.setAttribute("java-class", String.class.getName());
usernameAttr.setAttribute("optional", Boolean.toString(!this.auth));
documentation.appendChild(usernameAttr);
Element passwordAttr = document.createElement("attribute");
passwordAttr.setAttribute("name", "login.password");
passwordAttr.setAttribute("type", "std-String");
passwordAttr.setAttribute("namespace", TNS);
passwordAttr.setAttribute("java-class", String.class.getName());
passwordAttr.setAttribute("optional", Boolean.toString(!this.auth));
documentation.appendChild(passwordAttr);
parametersPart.setDocumentationElement(documentation);
def.addMessage(inMessage);
input.setMessage(inMessage);
// set the OUT parameters
Output output = def.createOutput();
Set<String> outParam = this.getOutParamNames();
Message outMessage = def.createMessage();
outMessage.setQName(new QName(TNS, this.name + "Response"));
outMessage.setUndefined(false);
Part resultsPart = def.createPart();
resultsPart.setName("map-Map");
resultsPart.setTypeName(new QName(TNS, "map-Map"));
outMessage.addPart(resultsPart);
documentation = document.createElement("wsdl:documentation");
for (String paramName : outParam) {
ModelParam param = this.getParam(paramName);
if (!param.internal) {
Part part = param.getWSDLPart(def);
Element attribute = document.createElement("attribute");
attribute.setAttribute("name", paramName);
attribute.setAttribute("type", part.getTypeName().getLocalPart());
attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
attribute.setAttribute("java-class", param.type);
attribute.setAttribute("optional", Boolean.toString(param.optional));
documentation.appendChild(attribute);
}
}
resultsPart.setDocumentationElement(documentation);
def.addMessage(outMessage);
output.setMessage(outMessage);
// set port type
Operation operation = def.createOperation();
operation.setName(this.name);
operation.setUndefined(false);
operation.setOutput(output);
operation.setInput(input);
PortType portType = def.createPortType();
portType.setQName(new QName(TNS, this.name + "PortType"));
portType.addOperation(operation);
portType.setUndefined(false);
def.addPortType(portType);
// SOAP binding
SOAPBinding soapBinding = new SOAPBindingImpl();
soapBinding.setStyle("rpc");
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
Binding binding = def.createBinding();
binding.setQName(new QName(TNS, this.name + "SoapBinding"));
binding.setPortType(portType);
binding.setUndefined(false);
binding.addExtensibilityElement(soapBinding);
BindingOperation bindingOperation = def.createBindingOperation();
bindingOperation.setName(operation.getName());
bindingOperation.setOperation(operation);
SOAPBody soapBody = new SOAPBodyImpl();
soapBody.setUse("literal");
soapBody.setNamespaceURI(TNS);
soapBody.setEncodingStyles(UtilMisc.toList("http://schemas.xmlsoap.org/soap/encoding/"));
BindingOutput bindingOutput = def.createBindingOutput();
bindingOutput.addExtensibilityElement(soapBody);
bindingOperation.setBindingOutput(bindingOutput);
BindingInput bindingInput = def.createBindingInput();
bindingInput.addExtensibilityElement(soapBody);
bindingOperation.setBindingInput(bindingInput);
SOAPOperation soapOperation = new SOAPOperationImpl();
// soapAction should be set to the location of the SOAP URI, or Visual Studio won't construct the correct SOAP message
soapOperation.setSoapActionURI(locationURI);
// this is the RPC/literal style. See http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
// this parameter is necessary or Apache Synapse won't recognize the WSDL
soapOperation.setStyle("rpc");
bindingOperation.addExtensibilityElement(soapOperation);
binding.addBindingOperation(bindingOperation);
def.addBinding(binding);
// Service port
Port port = def.createPort();
port.setBinding(binding);
port.setName(this.name + "Port");
if (locationURI != null) {
SOAPAddress soapAddress = new SOAPAddressImpl();
soapAddress.setLocationURI(locationURI);
port.addExtensibilityElement(soapAddress);
}
Service service = def.createService();
service.setQName(new QName(TNS, this.name));
service.addPort(port);
def.addService(service);
}
Aggregations