01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.dataretrieval.client;
20:
21: import org.apache.axiom.om.OMAbstractFactory;
22: import org.apache.axiom.om.OMElement;
23: import org.apache.axiom.om.OMFactory;
24: import org.apache.axiom.om.OMNamespace;
25: import org.apache.axis2.AxisFault;
26: import org.apache.axis2.client.ServiceClient;
27: import org.apache.axis2.context.ConfigurationContext;
28: import org.apache.axis2.dataretrieval.DRConstants;
29: import org.apache.axis2.description.AxisService;
30:
31: import javax.wsdl.Definition;
32: import javax.xml.namespace.QName;
33: import java.net.URL;
34:
35: public class MexClient extends ServiceClient {
36:
37: public MexClient(ConfigurationContext configContext,
38: AxisService axisService) throws AxisFault {
39: super (configContext, axisService);
40: }
41:
42: public MexClient(ConfigurationContext configContext,
43: Definition wsdl4jDefinition, QName wsdlServiceName,
44: String portName) throws AxisFault {
45: super (configContext, wsdl4jDefinition, wsdlServiceName,
46: portName);
47: }
48:
49: public MexClient(ConfigurationContext configContext, URL wsdlURL,
50: QName wsdlServiceName, String portName) throws AxisFault {
51: super (configContext, wsdlURL, wsdlServiceName, portName);
52: }
53:
54: public MexClient() throws AxisFault {
55: }
56:
57: /**
58: * Builds OMElement that makes up of SOAP body.
59: */
60: public OMElement setupGetMetadataRequest(String dialect,
61: String identifier) throws AxisFault {
62:
63: // Attempt to engage MEX module
64: /* try{
65: super.engageModule("metadataExchange");
66: }
67: catch (Exception e){
68: throw new AxisFault ("Unable to proceed with GetMetadata Request!", e);
69: } */
70:
71: OMFactory fac = OMAbstractFactory.getOMFactory();
72:
73: OMNamespace omNs = fac.createOMNamespace(
74: DRConstants.SPEC.NS_URI, DRConstants.SPEC.NS_PREFIX);
75:
76: OMElement method = fac.createOMElement(
77: DRConstants.SPEC.GET_METADATA, omNs);
78: if (dialect != null) {
79: OMElement dialect_Elem = fac.createOMElement(
80: DRConstants.SPEC.DIALET, omNs);
81:
82: dialect_Elem.setText(dialect);
83: method.addChild(dialect_Elem);
84: }
85: // create Identifier element
86: if (identifier != null) {
87: OMElement id_Elem = fac.createOMElement(
88: DRConstants.SPEC.IDENTIFIER, omNs);
89: id_Elem.setText(identifier);
90: method.addChild(id_Elem);
91: }
92: return method;
93: }
94: }
|