Problem with setting boolean to nil
Hi, I have found that the java code generated from a WSDL does not seem to support setting boolean fields to nil. For example - here is a snippet of the WSDL : and the java code generated to add this element to the soap request is as follows : namespace = ""; if (! namespace.equals("")) { prefix = xmlWriter.getPrefix(namespace); if (prefix == null) { prefix = generatePrefix(namespace); xmlWriter.writeStartElement(prefix,"ignoreConflict", namespace); xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } else { xmlWriter.writeStartElement(namespace,"ignoreConflict"); } } else { xmlWriter.writeStartElement("ignoreConflict"); } if (false) { writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","1",xmlWriter); } else { xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localIgnoreConflict)); } xmlWriter.writeEndElement(); Note the 'if' statement which actually writes the data to the element - it will never write the 'nil' attribute. I want to be able to indicate that the value of an element has not been set, rather than passing 'true' or 'false' as the boolean value. Is this possible??? I have tried this with both Axis2 v 1.3 & 1.4. Many Thanks Julie -- This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please notify the sender and delete the transmission. The contents of this e-mail are the opinion of the writer only and are not endorsed by the Mincom Group of companies unless expressly stated otherwise. --
Re: Problem with setting boolean to nil
Thanks for your reply Amila. I have tried as you suggested, but am getting compile errors now when compiling. This is the code snippet generated to delcare the boolean attriute. /** * field for IgnoreConflict */ protected java.lang.Boolean localIgnoreConflict ; /** * Auto generated getter method * @return java.lang.Boolean */ public java.lang.Boolean getIgnoreConflict(){ return localIgnoreConflict; } /** * Auto generated setter method * @param param IgnoreConflict */ public void setIgnoreConflict(java.lang.Boolean param){ this.localIgnoreConflict=param; } which it has created as a Boolean however the code generated to set this value is : while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); if (reader.isStartElement() && new javax.xml.namespace.QName("","ignoreConflict").equals(reader.getName())){ nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil";); if (!"true".equals(nillableValue) && !"1".equals(nillableValue)){ java.lang.String content = reader.getElementText(); object.setIgnoreConflict( org.apache.axis2.databinding.utils.ConverterUtil.convertToBoolean(content)); } else { reader.getElementText(); // throw away text nodes if any. } reader.next(); Note the call to setIgnoreConflict, which uses ConvertUtil.convertToBoolean This method returns a boolean, not a Boolean. public static boolean convertToBoolean(String s) { boolean returnValue = false; if ((s != null) && (s.length() > 0)) { if ("1".equals(s) || s.toLowerCase().equals("true")) { returnValue = true; } else if (!"0".equals(s) && !s.toLowerCase().equals("false")) { throw new RuntimeException("in valid string -" + s + " for boolean value"); } } return returnValue; } Hence causing the compile error. Is this a known problem, or have I done something wrong during the generation. If it is a known problem, I'm guessing I will have to modify the convertToBoolean method (assuming nothing else uses it), or is there another way around this problem?? Thanks Julie -- This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please notify the sender and delete the transmission. The contents of this e-mail are the opinion of the writer only and are not endorsed by the Mincom Group of companies unless expressly stated otherwise. --
Getting FaultString from SOAP message on Client
Hi, I am having some problems getting the FaultString out of the SOAP message returned to me from a service. I have generated my stubs using WSDL2Java from version 1.3 of Axis2. The following is the SOAP message returned : http://schemas.xmlsoap.org/soap/envelope/"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> http://exception.enterpriseservice.mincom.com ">p773:EnterpriseServiceConnectionException http://exception.enterpriseservice.mincom.com";> However, the stub throws an EnterpriseServiceConnectionException which contains a null ellipseConnectionManagerLogonResultDTO (which I guess makes sense from the result). I want to know if the faultstring is made available to the client stubs(as this is what holds the meaningful message in this case), and if so, how? Thanks Julie -- This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please notify the sender and delete the transmission. The contents of this e-mail are the opinion of the writer only and are not endorsed by the Mincom Group of companies unless expressly stated otherwise. --
Re: Getting FaultString from SOAP message on Client
Thanks for your feedback, however, the exception that is thrown is a EnterpriseServiceConnectionException Exception. This does not have a 'getFaultString' method, it only has a 'getFaultMessage' which returns the null ellipseConnectionManagerLogonResultDTO. Does this mean that the EnterpriseServiceConnectionException has been defined incorrectly in the WSDL? Thanks Julie You can get faultString etc. like in the catch block, exception.getFaultString() Upul On Feb 1, 2008 3:38 AM, <[EMAIL PROTECTED]> wrote: Hi, I am having some problems getting the FaultString out of the SOAP message returned to me from a service. I have generated my stubs using WSDL2Java from version 1.3 of Axis2. The following is the SOAP message returned : http://schemas.xmlsoap.org/soap/envelope/"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> http://exception.enterpriseservice.mincom.com ">p773:EnterpriseServiceConnectionException http://exception.enterpriseservice.mincom.com";> However, the stub throws an EnterpriseServiceConnectionException which contains a null ellipseConnectionManagerLogonResultDTO (which I guess makes sense from the result). I want to know if the faultstring is made available to the client stubs(as this is what holds the meaningful message in this case), and if so, how? Thanks Julie -- This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please notify the sender and delete the transmission. The contents of this e-mail are the opinion of the writer only and are not endorsed by the Mincom Group of companies unless expressly stated otherwise. --
Re: Getting FaultString from SOAP message on Client
Hi Upul Thanks very much for this. It worked a treat. You're right though, it does seem to be a complicated way to get the fault data Regards Julie Sorry, You can get the last envelope like this. And traverse the OMElement. There should be better solutions. org.apache.axiom.soap.SOAPEnvelope soap = stub._getServiceClient().getLastOperationContext().getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE ).getEnvelope(); Upul On Feb 1, 2008 7:42 AM, <[EMAIL PROTECTED]> wrote: Thanks for your feedback, however, the exception that is thrown is a EnterpriseServiceConnectionException Exception. This does not have a 'getFaultString' method, it only has a 'getFaultMessage' which returns the null ellipseConnectionManagerLogonResultDTO. Does this mean that the EnterpriseServiceConnectionException has been defined incorrectly in the WSDL? Thanks Julie You can get faultString etc. like in the catch block, exception.getFaultString() Upul On Feb 1, 2008 3:38 AM, <[EMAIL PROTECTED]> wrote: Hi, I am having some problems getting the FaultString out of the SOAP message returned to me from a service. I have generated my stubs using WSDL2Java from version 1.3 of Axis2. The following is the SOAP message returned : http://schemas.xmlsoap.org/soap/envelope/"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> http://exception.enterpriseservice.mincom.com ">p773:EnterpriseServiceConnectionException http://exception.enterpriseservice.mincom.com";> However, the stub throws an EnterpriseServiceConnectionException which contains a null ellipseConnectionManagerLogonResultDTO (which I guess makes sense from the result). I want to know if the faultstring is made available to the client stubs(as this is what holds the meaningful message in this case), and if so, how? Thanks Julie -- This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please notify the sender and delete the transmission. The contents of this e-mail are the opinion of the writer only and are not endorsed by the Mincom Group of companies unless expressly stated otherwise. --