我的肥皂要求中有头和身体 Soap request looks like this 这是我使用AsyncTask的完整java类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.rewads_screen1, container, false);
mAvailableReward = (Button) view.findViewById(R.id.Bt_AvailableReward);
mClaimedReward = (Button) view.findViewById(R.id.Bt_ClaimedReward);
mExpiredDisqualifiedReward = (Button) view.findViewById(R.id.Bt_ExpiredDisqualifiedReward);
mExpiredDisqualifiedReward.setEnabled(false);
mBT_ClaimItNw1 = (Button) view.findViewById(R.id.Bt_ClaimItNow1);
mIV_ArrowNext1 = (ImageView) view.findViewById(R.id.IV_NextArrow1);
mBT_ViewRewardTracker1 = (Button) view.findViewById(R.id.Bt_viewRewardTracker1);
mIV_ArrowNext1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getFragmentManager().beginTransaction().replace(R.id.rewardScreenLayout, new Reward_screen_fragment2()).commit();
}
});
mBT_ClaimItNw1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getActivity(), RewardConfiirmation.class);
startActivity(i);
}
});
mBT_ViewRewardTracker1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getFragmentManager().beginTransaction().replace(R.id.rewardScreenLayout, new CongratulationsFragment()).addToBackStack(null).commit();
}
});
mLoginbean.setLoginType("CNUM");
mLoginbean.setBillPhone("103488321");
mLoginbean.setBillPhoneFormatted("format");
mLoginbean.setConnectionID(77093196);
mLoginbean.setCreateUser("WebUser");
mLoginbean.setCustomerID(18334267);
mLoginbean.setCustomerName("Steven Cohen");
mLoginbean.setCustomerZipCode("349949502");
mLoginbean.setEmailAddress("gjh56tys6y");
mLoginbean.setEmailSaved(true);
mLoginbean.setLoginProductTypes("heloo");
mLoginbean.setLoginSuccessful(true);
mLoginbean.setLoginTried(true);
mLoginbean.setZipCode("h3hd");
mLoginbean.setRedemptionIDProductGroup("sdfasdf");
mLoginbean.setOptIn("false");
mLoginbean.setRedemptionID("gdfgj");
mLoginbean.setProductName("dfgj");
mClaimedReward.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SoapObject request = new SoapObject(NameSpace, Methodname);
PropertyInfo tabProp = new PropertyInfo();
tabProp.setName("AttLogins");
tabProp.setValue(new SoapObject(NameSpace, "AttLogin").
addProperty("LoginType","CNUM").
addProperty("BillPhone","hgh").
addProperty("BillPhoneFormatted", "fgf").
addProperty("CreateUser","fg").
addProperty("ConnectionID",77093196).
addProperty("CustomerID",39).
addProperty("CustomerZipCode","fgfg").
addProperty("LoginTried", true).
addProperty("LoginSuccessful",true).
addProperty("OptIn","sdfg").
addProperty("CustomerName","fg").
addProperty("EmailAddress","fg").
addProperty("EmailSaved", false).
addProperty("LoginProductTypes","fg").
addProperty("RedemptionID", "fg").
addProperty("RedemptionIDProductGroup", "fg").
addProperty("ProductName","df").
addProperty("ZipCode", "dfd"));
request.addProperty(tabProp);
new getReedemedProductInfo(request,Methodname).execute();
}
});
return view;
}
class getReedemedProductInfo extends AsyncTask<Void, Void, SoapObject> {
SoapObject mPostData;
String mMethod;
private ProgressDialog dialog = new ProgressDialog(getActivity());
public getReedemedProductInfo(SoapObject postData,
String method) {
mPostData = postData;
mMethod = method;
}
@Override
protected SoapObject doInBackground(Void... params) {;
Log.d("Request", mPostData.toString());
String SOAP_ACTION = NameSpace+mMethod;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.headerOut=new Element[1];
envelope.headerOut[0]=buildAuthHeader();
envelope.bodyOut=mPostData;
envelope.implicitTypes = true;
envelope.setAddAdornments(false);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.debug = true;
// Log.d("envelop",envelope.toString());
androidHttpTransport.call(Soap_Action, envelope);
if (envelope.bodyIn instanceof SoapFault) {
final SoapFault sf = (SoapFault) envelope.bodyIn;
//response = (SoapObject) envelope.bodyIn;
Log.d("Soap fault",sf.toString());
}
else {
//response = resultsRequestSOAP;
Log.d("response", "" + response.toString());
}
} catch (Exception e) {
Log.d("errorResponse", e.getMessage() + response);
e.printStackTrace();
}
return response;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
dialog.setMessage("Validating ,Please wait..");
dialog.show();
}
@Override
protected void onPostExecute(SoapObject soapObject) {
super.onPostExecute(soapObject);
if (dialog.isShowing()) {
dialog.dismiss();
}
}
}
private Element buildAuthHeader() {
Element h = new Element().createElement(NameSpace, "AuthHeader");
Element username = new Element().createElement(NameSpace, "SessionKey");
username.addChild(Node.TEXT, "00000000-0000-0000-0000-000000000000");
h.addChild(Node.ELEMENT, username);
return h;
}
/*String s = "AuthenticationKey";
if (soapObject != null) {
SoapObject root = (SoapObject) response.getProperty(0);
String property = root.getProperty("AuthenticationKey").toString();
System.out.println("Authenticationkey " + property);
} else {
System.out.println("response is empty");
}*/
/* header = new Element[1];
header[0] = new Element().createElement(NameSpace, "AuthHeader");
Element sessionkey = new Element().createElement(NameSpace, "SessionKey");
sessionkey.addChild(Node.TEXT, ("00000000-0000-0000-0000-000000000000"));
header[0].addChild(Node.ELEMENT, sessionkey);*/
}
我在errorSystem.Web.Services.Protocols.SoapException中遇到soap故障:服务器无法处理请求。 ---&GT; System.ArgumentOutOfRangeException:索引超出范围。必须是非负数且小于集合的大小。 参数名称:index
我错过了任何东西。我不确定我的标题和身体是否正确陷害。请建议一些有用的东西......谢谢。