1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.axis.message.addressing;
19
20 import javax.xml.soap.SOAPElement;
21
22 import org.apache.axis.utils.XMLUtils;
23 import org.apache.axis.encoding.SimpleType;
24
25 import org.apache.axis.message.addressing.util.TextExtractor;
26
27 import org.w3c.dom.Attr;
28 import org.w3c.dom.Element;
29
30 import javax.xml.namespace.QName;
31
32 /***
33 * Java content class for ServiceNameType complex type.
34 * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at http://schemas.xmlsoap.org/ws/2004/08/addressing line 67)
35 * <p>
36 * <pre>
37 * <complexType name="ServiceNameType">
38 * <simpleContent>
39 * <extension base="<http://www.w3.org/2001/XMLSchema>QName">
40 * <attribute name="PortName" type="{http://www.w3.org/2001/XMLSchema}NCName" />
41 * </extension>
42 * </simpleContent>
43 * </complexType>
44 * </pre>
45 *
46 * @author Davanum Srinivas (dims@yahoo.com)
47 */
48 public class ServiceNameType extends AttributedQName
49 implements SimpleType {
50
51 /***
52 * Field port
53 */
54 private String port;
55
56 public ServiceNameType(QName qname) {
57 super(qname);
58 }
59
60 /***
61 * Constructor ServiceName
62 *
63 * @param qname
64 * @param port
65 */
66 public ServiceNameType(QName qname, String port) {
67 super(qname);
68 this.port = port;
69 }
70
71 /***
72 * Constructor ServiceName
73 *
74 * @param namespace
75 * @param localName
76 */
77 public ServiceNameType(String namespace,
78 String localName) {
79 super(namespace, localName);
80 }
81
82 /***
83 * Constructor ServiceName
84 *
85 * @param serviceName
86 */
87 public ServiceNameType(ServiceNameType serviceName) {
88 super(serviceName);
89 this.port = serviceName.getPort();
90 }
91
92 /***
93 * Method getPort
94 *
95 * @return
96 */
97 public String getPort() {
98 return port;
99 }
100
101 /***
102 * Method setPort
103 *
104 * @param port
105 */
106 public void setPort(String port) {
107 this.port = port;
108 }
109
110 /***
111 * append DOM node to parent
112 *
113 * @param parent
114 */
115 public void append(Element parent, String elementName) {
116 Element sn = parent.getOwnerDocument().createElementNS(
117 Constants.NS_URI_ADDRESSING_DEFAULT,
118 elementName);
119 String value = XMLUtils.getStringForQName(this, sn);
120 sn.appendChild(parent.getOwnerDocument().createTextNode(value));
121 if (getPort() != null) {
122 sn.setAttribute(Constants.PORT_NAME, getPort());
123 }
124 parent.appendChild(sn);
125 }
126
127 public static ServiceNameType fromSOAPElement(SOAPElement element)
128 throws Exception {
129 String value = TextExtractor.getText(element);
130 QName qname = TextExtractor.getQName(value, element);
131 String portName = element.getAttribute(Constants.PORT_NAME);
132 portName = (portName == null || portName.length() == 0) ?
133 null : portName;
134 return new ServiceNameType(qname, portName);
135 }
136
137 public static ServiceNameType fromElement(Element element)
138 throws Exception {
139 String value = TextExtractor.getText(element);
140 QName qname = XMLUtils.getQNameFromString(value, element);
141 String portName = element.getAttribute(Constants.PORT_NAME);
142 portName = (portName == null || portName.length() == 0) ?
143 null : portName;
144 return new ServiceNameType(qname, portName);
145 }
146
147
148
149
150 private static org.apache.axis.description.TypeDesc typeDesc =
151 new org.apache.axis.description.TypeDesc(ServiceNameType.class, true);
152
153 static {
154 typeDesc.setXmlType(new javax.xml.namespace.QName(Constants.NS_URI_ADDRESSING_DEFAULT, "ServiceNameType"));
155 org.apache.axis.description.AttributeDesc attrField = new org.apache.axis.description.AttributeDesc();
156 attrField.setFieldName("port");
157 attrField.setXmlName(new javax.xml.namespace.QName("", "PortName"));
158 attrField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
159 typeDesc.addFieldDesc(attrField);
160 }
161
162 /***
163 * Return type metadata object
164 */
165 public static org.apache.axis.description.TypeDesc getTypeDesc() {
166 return typeDesc;
167 }
168
169
170 /***
171 * Get Custom Serializer
172 */
173 public static org.apache.axis.encoding.Serializer getSerializer(
174 java.lang.String mechType,
175 java.lang.Class _javaType,
176 javax.xml.namespace.QName _xmlType) {
177 return
178 new org.apache.axis.encoding.ser.SimpleSerializer(
179 _javaType, _xmlType, typeDesc);
180 }
181
182 /***
183 * Get Custom Deserializer
184 */
185 public static org.apache.axis.encoding.Deserializer getDeserializer(
186 java.lang.String mechType,
187 java.lang.Class _javaType,
188 javax.xml.namespace.QName _xmlType) {
189 return
190 new org.apache.axis.encoding.ser.SimpleDeserializer(
191 _javaType, _xmlType, typeDesc);
192 }
193
194 }
195
196