public ExtensibilityElement unmarshall( Class parentType, QName elementType, Element el, Definition def, ExtensionRegistry extReg) throws WSDLException { SOAPBody soapBody = (SOAPBody) extReg.createExtension(parentType, elementType); String partsStr = DOMUtils.getAttribute(el, SOAPConstants.ATTR_PARTS); String use = DOMUtils.getAttribute(el, SOAPConstants.ATTR_USE); String encStyleStr = DOMUtils.getAttribute(el, SOAPConstants.ATTR_ENCODING_STYLE); String namespaceURI = DOMUtils.getAttribute(el, Constants.ATTR_NAMESPACE); String requiredStr = DOMUtils.getAttributeNS(el, Constants.NS_URI_WSDL, Constants.ATTR_REQUIRED); if (partsStr != null) { soapBody.setParts(StringUtils.parseNMTokens(partsStr)); } if (use != null) { soapBody.setUse(use); } if (encStyleStr != null) { soapBody.setEncodingStyles(StringUtils.parseNMTokens(encStyleStr)); } if (namespaceURI != null) { soapBody.setNamespaceURI(namespaceURI); } if (requiredStr != null) { soapBody.setRequired(new Boolean(requiredStr)); } return soapBody; }
/** * @param contextURI * @param wsdlURI * @param userName * @param password * @return * @throws WSDLException */ public Definition readWSDL(String contextURI, String wsdlURI, String userName, String password) throws WSDLException { try { if (verbose) { System.out.println( "Retrieving document at '" + wsdlURI + "'" //$NON-NLS-1$ //$NON-NLS-2$ + (contextURI == null ? "." : ", relative to '" + contextURI + "'.")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } URL contextURL = (contextURI != null) ? StringUtils.getURL(null, contextURI) : null; URL url = StringUtils.getURL(contextURL, wsdlURI); URLConnection urlConn = url.openConnection(); URLHelper.setCredentials(urlConn, userName, password); InputStream inputStream = urlConn.getInputStream(); InputSource inputSource = new InputSource(urlConn.getInputStream()); inputSource.setSystemId(url.toString()); Document doc = getDocument(inputSource, url.toString()); inputStream.close(); Definition def = readWSDL(url.toString(), doc); return def; } catch (WSDLException e) { throw e; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new WSDLException( WSDLException.OTHER_ERROR, "Unable to resolve imported document at '" + wsdlURI //$NON-NLS-1$ + (contextURI == null ? "'." : "', relative to '" + contextURI + "'."), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ e); } }
public void marshall( Class parentType, QName elementType, ExtensibilityElement extension, PrintWriter pw, Definition def, ExtensionRegistry extReg) throws WSDLException { SOAPBody soapBody = (SOAPBody) extension; if (soapBody != null) { String tagName = DOMUtils.getQualifiedValue(SOAPConstants.NS_URI_SOAP, "body", def); if (parentType != null && MIMEPart.class.isAssignableFrom(parentType)) { pw.print(" "); } pw.print(" <" + tagName); DOMUtils.printAttribute( SOAPConstants.ATTR_PARTS, StringUtils.getNMTokens(soapBody.getParts()), pw); DOMUtils.printAttribute(SOAPConstants.ATTR_USE, soapBody.getUse(), pw); DOMUtils.printAttribute( SOAPConstants.ATTR_ENCODING_STYLE, StringUtils.getNMTokens(soapBody.getEncodingStyles()), pw); DOMUtils.printAttribute(Constants.ATTR_NAMESPACE, soapBody.getNamespaceURI(), pw); Boolean required = soapBody.getRequired(); if (required != null) { DOMUtils.printQualifiedAttribute(Constants.Q_ATTR_REQUIRED, required.toString(), def, pw); } pw.println("/>"); } }