📄 call.java
字号:
// // Properties and the shortcuts for common ones. // /** * Allows you to set a named property to the passed in value. * There are a few known properties (like username, password, etc) * that are variables in Call. The rest of the properties are * stored in a Hashtable. These common properties should be * accessed via the accessors for speed/type safety, but they may * still be obtained via this method. It's up to one of the * Handlers (or the Axis engine itself) to go looking for * one of them. * * There are various well defined properties defined in the * JAX-RPC specification and declared in the Call and Stub classes. * It is not possible to set any other properties beginning in java. or * javax. that are not in the specification. * @see javax.xml.rpc.Stub * @see javax.xml.rpc.Call * * There are other properties implemented in this class above and * beyond those of the JAX-RPC spec * Specifically, ATTACHMENT_ENCAPSULATION_FORMAT, CONNECTION_TIMEOUT_PROPERTY, * and TRANSPORT_NAME. * * It is intended that all future Axis-specific properties will begin * with axis. or apache. To ensure integration with future versions Axis, * use different prefixes for your own properties. * * Axis developers: keep this in sync with propertyNames below * @see #ATTACHMENT_ENCAPSULATION_FORMAT * @see #TRANSPORT_NAME * @see #CONNECTION_TIMEOUT_PROPERTY * @param name Name of the property * @param value Value of the property */ public void setProperty(String name, Object value) { if (name == null || value == null) { throw new JAXRPCException( Messages.getMessage(name == null ? "badProp03" : "badProp04")); } else if (name.equals(USERNAME_PROPERTY)) { verifyStringProperty(name, value); setUsername((String) value); } else if (name.equals(PASSWORD_PROPERTY)) { verifyStringProperty(name, value); setPassword((String) value); } else if (name.equals(SESSION_MAINTAIN_PROPERTY)) { verifyBooleanProperty(name, value); setMaintainSession(((Boolean) value).booleanValue()); } else if (name.equals(OPERATION_STYLE_PROPERTY)) { verifyStringProperty(name, value); setOperationStyle((String) value); if (getOperationStyle() == Style.DOCUMENT || getOperationStyle() == Style.WRAPPED) { setOperationUse(Use.LITERAL_STR); } else if (getOperationStyle() == Style.RPC) { setOperationUse(Use.ENCODED_STR); } } else if (name.equals(SOAPACTION_USE_PROPERTY)) { verifyBooleanProperty(name, value); setUseSOAPAction(((Boolean) value).booleanValue()); } else if (name.equals(SOAPACTION_URI_PROPERTY)) { verifyStringProperty(name, value); setSOAPActionURI((String) value); } else if (name.equals(ENCODINGSTYLE_URI_PROPERTY)) { verifyStringProperty(name, value); setEncodingStyle((String) value); } else if (name.equals(Stub.ENDPOINT_ADDRESS_PROPERTY)) { verifyStringProperty(name, value); setTargetEndpointAddress((String) value); } else if ( name.equals(TRANSPORT_NAME) ) { verifyStringProperty(name, value); transportName = (String) value ; if (transport != null) { transport.setTransportName((String) value); } } else if ( name.equals(ATTACHMENT_ENCAPSULATION_FORMAT) ) { verifyStringProperty(name, value); if(!value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_MIME ) && !value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_MTOM ) && !value.equals(ATTACHMENT_ENCAPSULATION_FORMAT_DIME )) throw new JAXRPCException( Messages.getMessage("badattachmenttypeerr", new String[] { (String) value, ATTACHMENT_ENCAPSULATION_FORMAT_MIME + " " +ATTACHMENT_ENCAPSULATION_FORMAT_MTOM + " " +ATTACHMENT_ENCAPSULATION_FORMAT_DIME })); } else if (name.equals(CONNECTION_TIMEOUT_PROPERTY)) { verifyIntegerProperty(name,value); setTimeout((Integer)value); } else if (name.equals(STREAMING_PROPERTY)) { verifyBooleanProperty(name, value); setStreaming(((Boolean) value).booleanValue()); } else if (name.equals(CHARACTER_SET_ENCODING)) { verifyStringProperty(name, value); } else if (name.startsWith("java.") || name.startsWith("javax.")) { throw new JAXRPCException( Messages.getMessage("badProp05", name)); } myProperties.put(name, value); } // setProperty /** * Verify that the type of the object is a String, and throw * an i18n-ized exception if not * @param name * @param value * @throws JAXRPCException if value is not a String */ private void verifyStringProperty(String name, Object value) { if (!(value instanceof String)) { throw new JAXRPCException( Messages.getMessage("badProp00", new String[] {name, "java.lang.String", value.getClass().getName()})); } } /** * Verify that the type of the object is a Boolean, and throw * an i18n-ized exception if not * @param name * @param value * @throws JAXRPCException if value is not a Boolean */ private void verifyBooleanProperty(String name, Object value) { if (!(value instanceof Boolean)) { throw new JAXRPCException( Messages.getMessage("badProp00", new String[] {name, "java.lang.Boolean", value.getClass().getName()})); } } /** * Verify that the type of the object is an Integer, and throw * an i18n-ized exception if not * @param name * @param value * @throws JAXRPCException if value is not an Integer */ private void verifyIntegerProperty(String name, Object value) { if (!(value instanceof Integer)) { throw new JAXRPCException( Messages.getMessage("badProp00", new String[] {name, "java.lang.Integer", value.getClass().getName()})); } } /** * Returns the value associated with the named property. * * @param name the name of the property * @return Object value of the property or null if the property is not set * @throws JAXRPCException if the requested property is not a supported property */ public Object getProperty(String name) { if (name == null || !isPropertySupported(name)) { throw new JAXRPCException(name == null ? Messages.getMessage("badProp03") : Messages.getMessage("badProp05", name)); } return myProperties.get(name); } // getProperty /** * Removes (if set) the named property. * * @param name name of the property to remove */ public void removeProperty(String name) { if (name == null || !isPropertySupported(name)) { throw new JAXRPCException(name == null ? Messages.getMessage("badProp03") : Messages.getMessage("badProp05", name)); } myProperties.remove(name); } // removeProperty /** * Configurable properties supported by this Call object. */ private static ArrayList propertyNames = new ArrayList(); static { propertyNames.add(USERNAME_PROPERTY); propertyNames.add(PASSWORD_PROPERTY); propertyNames.add(SESSION_MAINTAIN_PROPERTY); propertyNames.add(OPERATION_STYLE_PROPERTY); propertyNames.add(SOAPACTION_USE_PROPERTY); propertyNames.add(SOAPACTION_URI_PROPERTY); propertyNames.add(ENCODINGSTYLE_URI_PROPERTY); propertyNames.add(Stub.ENDPOINT_ADDRESS_PROPERTY); propertyNames.add(TRANSPORT_NAME); propertyNames.add(ATTACHMENT_ENCAPSULATION_FORMAT); propertyNames.add(CONNECTION_TIMEOUT_PROPERTY); propertyNames.add(CHARACTER_SET_ENCODING); } public Iterator getPropertyNames() { return propertyNames.iterator(); } public boolean isPropertySupported(String name) { return propertyNames.contains(name) || (!name.startsWith("java.") && !name.startsWith("javax.")); } /** * Set the username. * * @param username the new user name */ public void setUsername(String username) { this.username = username; } // setUsername /** * Get the user name. * * @return the user name */ public String getUsername() { return username; } // getUsername /** * Set the password. * * @param password plain-text copy of the password */ public void setPassword(String password) { this.password = password; } // setPassword /** * Get the password. * * @return a plain-text copy of the password */ public String getPassword() { return password; } // getPassword /** * Determine whether we'd like to track sessions or not. This * overrides the default setting from the service. * This just passes through the value into the MessageContext. * Note: Not part of JAX-RPC specification. * * @param yesno true if session state is desired, false if not. */ public void setMaintainSession(boolean yesno) { maintainSession = yesno; } /** * Get the value of maintainSession flag. * * @return true if session is maintained, false otherwise */ public boolean getMaintainSession() { return maintainSession; } /** * Set the operation style: "document", "rpc" * @param operationStyle string designating style */ public void setOperationStyle(String operationStyle) { Style style = Style.getStyle(operationStyle, Style.DEFAULT); setOperationStyle(style); } // setOperationStyle /** * Set the operation style * * @param operationStyle */ public void setOperationStyle(Style operationStyle) { if (operation == null) { operation = new OperationDesc(); } operation.setStyle(operationStyle); // If no one has explicitly set the use, we should track // the style. If it's non-RPC, default to LITERAL. if (!useExplicitlySet) { if (operationStyle != Style.RPC) { operation.setUse(Use.LITERAL); } } // If no one has explicitly set the encodingStyle, we should // track the style. If it's RPC, default to SOAP-ENC, otherwise // default to "". if (!encodingStyleExplicitlySet) { String encStyle = ""; if (operationStyle == Style.RPC) { // RPC style defaults to encoded, otherwise default to literal encStyle = msgContext.getSOAPConstants().getEncodingURI(); } msgContext.setEncodingStyle(encStyle); } } /** * Get the operation style. * * @return the <code>Style</code> of the operation */ public Style getOperationStyle() { if (operation != null) { return operation.getStyle(); } return Style.DEFAULT; } // getOperationStyle /** * Set the operation use: "literal", "encoded" * @param operationUse string designating use */ public void setOperationUse(String operationUse) { Use use = Use.getUse(operationUse, Use.DEFAULT); setOperationUse(use); } // setOperationUse /** * Set the operation use * @param operationUse */ public void setOperationUse(Use operationUse) { useExplicitlySet = true; if (operation == null) { operation = new OperationDesc(); } operation.setUse(operationUse);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -