1 57 58 package com.myeis.wsdl.extensions.j2c.myeis; 59 60 import java.io.*; 61 import java.util.*; 62 import javax.wsdl.*; 63 import javax.xml.namespace.*; 64 import javax.wsdl.extensions.*; 65 import com.ibm.wsdl.*; 66 import com.ibm.wsdl.util.xml.*; 67 68 73 public class MyEISBindingSerializer 74 implements 75 javax.wsdl.extensions.ExtensionDeserializer, 76 javax.wsdl.extensions.ExtensionSerializer, 77 java.io.Serializable { 78 81 public MyEISBindingSerializer() { 82 super(); 83 } 84 85 88 public void marshall( 89 Class parentType, 90 javax.xml.namespace.QName extensionType, 91 javax.wsdl.extensions.ExtensibilityElement extension, 92 java.io.PrintWriter pw, 93 javax.wsdl.Definition def, 94 javax.wsdl.extensions.ExtensionRegistry extReg) 95 throws javax.wsdl.WSDLException { 96 97 if (extension == null) 98 return; 99 100 String TPrefix = null; 102 Map nameSpaces = def.getNamespaces(); 103 Iterator i = nameSpaces.keySet().iterator(); 104 105 while (i.hasNext()) { 106 String prefix = (String ) i.next(); 107 String namespaceURI = (String ) nameSpaces.get(prefix); 108 if (namespaceURI.equals(MyEISBindingConstants.NS_URI)) { 109 TPrefix = prefix; 110 break; 111 } 112 } 113 114 if (TPrefix == null) 116 throw new WSDLException( 117 "001", 118 "The EIS binding namespace was not found in the definition"); 119 120 if (extension instanceof MyEISBinding) { 121 MyEISBinding binding = (MyEISBinding) extension; 122 pw.print(" <" + TPrefix + ":binding"); 123 124 Boolean required = extension.getRequired(); 125 if (required != null) { 126 DOMUtils.printQualifiedAttribute( 127 Constants.Q_ATTR_REQUIRED, 128 required.toString(), 129 def, 130 pw); 131 } 132 133 pw.println("/>"); 134 } else 135 if (extension instanceof MyEISOperation) { 136 MyEISOperation operation = (MyEISOperation) extension; 137 pw.print(" <" + TPrefix + ":operation"); 138 139 if (operation.getFunctionName() != null) { 140 DOMUtils.printAttribute("functionName", operation.getFunctionName(), pw); 141 } 142 143 Boolean required = extension.getRequired(); 144 if (required != null) { 145 DOMUtils.printQualifiedAttribute( 146 Constants.Q_ATTR_REQUIRED, 147 required.toString(), 148 def, 149 pw); 150 } 151 152 pw.println("/>"); 153 } else 154 if (extension instanceof MyEISAddress) { 155 MyEISAddress address = (MyEISAddress) extension; 156 pw.print(" <" + TPrefix + ":address"); 157 158 if (address.getRepositoryLocation() != null) { 159 DOMUtils.printAttribute("repositoryLocation", address.getRepositoryLocation(), pw); 160 } 161 162 Boolean required = extension.getRequired(); 163 if (required != null) { 164 DOMUtils.printQualifiedAttribute( 165 Constants.Q_ATTR_REQUIRED, 166 required.toString(), 167 def, 168 pw); 169 } 170 pw.println("/>"); 171 } 172 } 173 176 public javax.wsdl.extensions.ExtensibilityElement unmarshall( 177 Class parentType, 178 javax.xml.namespace.QName elementType, 179 org.w3c.dom.Element el, 180 javax.wsdl.Definition def, 181 javax.wsdl.extensions.ExtensionRegistry extReg) 182 throws javax.wsdl.WSDLException { 183 184 javax.wsdl.extensions.ExtensibilityElement returnValue = null; 185 186 if (MyEISBindingConstants.Q_ELEM_BINDING.equals(elementType)) { 187 MyEISBinding binding = new MyEISBinding(); 188 189 return binding; 190 } else 191 if (MyEISBindingConstants.Q_ELEM_OPERATION.equals(elementType)) { 192 MyEISOperation operation = new MyEISOperation(); 193 194 String functionName = DOMUtils.getAttribute(el, "functionName"); 195 if (functionName != null) { 196 operation.setFunctionName(functionName); 197 } 198 return operation; 199 } else 200 if (MyEISBindingConstants.Q_ELEM_ADDRESS.equals(elementType)) { 201 MyEISAddress address = new MyEISAddress(); 202 203 String repositoryLocation = DOMUtils.getAttribute(el, "repositoryLocation"); 204 if (repositoryLocation != null) { 205 address.setRepositoryLocation(repositoryLocation); 206 } 207 return address; 208 } 209 210 return returnValue; 211 } 212 } | Popular Tags |