[英]Java webservice complex types
我正在使用ksoap2和在tomcat,axis2上運行的java webservice的android應用程序。
Web服務中有一個方法返回:
public class RecipeSmallReturnType
{
public int mId;
public String mName;
public String mDescription;
public String mUsername;
public int mDifficulty;
public int mServeCount;
public int mPreparationTime;
public float mTotalRating;
public int mNumOfVotes;
public int mOwnerId;
public int mUserRating;
public int mNumOfViews;
public String mReleaseDate;
}
當我在本地PC上使用Web服務時(使用new-> Web服務等),我得到了一個填充有數據的這種類型的數組。
但。 當我發布它時,我得到了這種類型的數組-但其中沒有數據...
有任何想法嗎? 也許我需要添加一些罐子? 可能是什么問題?
我堅持了將近一個星期。
請請我需要幫助
我還在Android中實現了返回類型:
public class RecipeSmallReturnType implements KvmSerializable
{
public int mId;
public String mName;
public String mDescription;
public String mUsername;
public int mDifficulty;
public int mServeCount;
public int mPreparationTime;
public float mTotalRating;
public int mNumOfVotes;
public int mOwnerId;
public int mUserRating;
public int mNumOfViews;
public String mReleaseDate;
public Object getProperty( int param )
{
switch( param )
{
case 0: return new Integer( mId );
case 1: return mName;
case 2: return mDescription;
case 3: return mUsername;
case 4: return new Integer( mDifficulty );
case 5: return new Integer( mServeCount );
case 6: return new Integer( mPreparationTime );
case 7: return new Float( mTotalRating );
case 8: return new Integer( mNumOfVotes );
case 9: return new Integer( mOwnerId );
case 10: return new Integer( mUserRating );
case 11: return new Integer( mNumOfViews );
case 12: return mReleaseDate;
default: return null;
}
}
public int getPropertyCount()
{
return 13;
}
public void getPropertyInfo( int param, Hashtable arg1, PropertyInfo arg2)
{
switch( param )
{
case 0:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mId";
break;
case 1:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "mName";
break;
case 2:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "mDescription";
break;
case 3:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "mUsername";
break;
case 4:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mDifficulty";
break;
case 5:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mServeCount";
break;
case 6:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mPreparationTime";
break;
case 7:
arg2.type = Float.class;
arg2.name = "mTotalRating";
break;
case 8:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mNumOfVotes";
break;
case 9:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mOwnerId";
break;
case 10:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mUserRating";
break;
case 11:
arg2.type = PropertyInfo.INTEGER_CLASS;
arg2.name = "mNumOfViews";
break;
case 12:
arg2.type = PropertyInfo.STRING_CLASS;
arg2.name = "mReleaseDate";
break;
default: break;
}
}
public void setProperty( int param, Object obj )
{
switch( param )
{
case 0: mId = (Integer)obj; break;
case 1: mName = (String)obj; break;
case 2: mDescription = (String)obj; break;
case 3: mUsername = (String)obj; break;
case 4: mDifficulty = (Integer)obj; break;
case 5: mServeCount = (Integer)obj; break;
case 6: mPreparationTime = (Integer)obj; break;
case 7: mTotalRating = (Float)obj; break;
case 8: mNumOfVotes = (Integer)obj; break;
case 9: mOwnerId = (Integer)obj; break;
case 10: mUserRating = (Integer)obj; break;
case 11: mNumOfViews = (Integer)obj; break;
case 12: mReleaseDate = (String)obj; break;
default: return;
}
}
}
但是我得到的是:
searchRecipesNewResponse{return=RecipeSmallReturnType{}; return=RecipeSmallReturnType{}; return=RecipeSmallReturnType{}; return=RecipeSmallReturnType{}; return=RecipeSmallReturnType{}; }
而不是充滿數據(當Web服務不在主機上而是在本地PC上時,我會獲取數據)
約夫
在RecipeSmallReturnType中實現KSerializable類。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.