manish-kukreja / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Return SoapFault when call WSDL #85

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I'm using ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar
2. Call webservice wsdl return int value

What is the expected output? What do you see instead?
I want to return value 1 (register success) but i saw SoapFault Object.

What version of the product are you using? On what operating system?
I'm using Eclipse Indigo, Tomcat server 7.0, Axis 2 and Windows XP Professional.

Another information:

My service method implement 

public int registerHoliday(String employeeId, String leaveTypeId,
            String startDate, String endDate, String startTime, String endTime,
            String note, String reason) throws Exception {
        String holidayId = Constants.EMPTY_STRING;
        boolean exist = true;
        while (exist) {
            holidayId = RandomString.generateId(10);
            if (holidayId != null && !Constants.EMPTY_STRING.equals(holidayId)) {
                Holiday tmpHoliday = findHolidayById(holidayId);
                if (tmpHoliday != null) {
                    if (holidayId.equals(tmpHoliday.getHolidayId())) {
                        exist = true;
                    } else {
                        exist = false;
                    }
                }
            }
        }

        // set query and
        this.query = Constants.QUERY_INSERT_HOLIDAY;
        this.conn = this.getConn();

        // set query and
        PreparedStatement prest = this.conn.prepareStatement(this.query);
        prest.setString(1, holidayId);
        java.util.Date dt1 = (java.util.Date) HrUtils.str2Date(startDate);
        java.sql.Date sqlDt1 = new java.sql.Date(dt1.getTime());
        java.util.Date dt2 = (java.util.Date) HrUtils.str2Date(endDate);
        java.sql.Date sqlDt2 = new java.sql.Date(dt2.getTime());
        prest.setDate(2, sqlDt1);
        prest.setDate(3, sqlDt2);
        prest.setString(4, startTime);
        prest.setString(5, endTime);
        prest.setString(6, reason);
        prest.setString(7, note);
        java.sql.Date sqlDt3 = new java.sql.Date(new java.util.Date().getTime());
        prest.setDate(8, sqlDt3);
        prest.setString(9, employeeId);
        prest.setString(10, Constants.STATUS_ID_NEW);
        prest.setString(11, leaveTypeId);

        return prest.executeUpdate();
    }

My method call service from Android:
public static Object callUpdate(String methodName,
            HashMap<String, String> params) {

        if (methodName == null || Constants.EMPTY_STRING.equals(methodName)) {
            return null;
        }
        SoapObject request = new SoapObject(Constants.KSOAP2_NAMESPACE,
                methodName);

        if (params != null) {
            Set<String> keys = params.keySet();
            String key = Constants.EMPTY_STRING;
            for (Iterator<String> i = keys.iterator(); i.hasNext();) {
                key = (String) i.next();
                request.addProperty(key, params.get(key));
            }
        }
        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        soapEnvelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(
                Constants.KSOAP2_URL);
        androidHttpTransport.debug = true;
        try {
            String soapAction = HrUtils.join(Constants.KSOAP2_NAMESPACE,
                    Constants.STRING_SLASH, methodName);
            androidHttpTransport.call(soapAction, soapEnvelope);

            return soapEnvelope.getResponse();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

My XML file:
<xs:element name="registerHoliday">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="employeeId" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="leaveTypeId" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="startDate" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="endDate" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="startTime" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="endTime" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="note" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="reason" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="registerHolidayResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>

My XML result when call from browser:
<ns:registerHolidayResponse xmlns:ns="http://android.hr">
<ns:return>1</ns:return>
</ns:registerHolidayResponse>

And debug info via image attach file

Original issue reported on code.google.com by phuc.q....@gmail.com on 23 Sep 2011 at 10:35

Attachments:

GoogleCodeExporter commented 9 years ago
Well. You have to look at the message of the soapfault. This is not an issue 
with ksoap but with your code. We can not do your debugging. 

Original comment by mosa...@gmail.com on 23 Sep 2011 at 5:45