当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Parsing Soap Service use of Retrofit I am facing exception like this(i.e)mismatched body model in the class envelope model in the response

问题描述:

While parsing response in Soap Services use of Retrofit iam facing this exception.My exception is below

 Failure: org.simpleframework.xml.core.ElementException: Element 'Body' does not have a match in class org.cainfo.arun.model.response.VerifyMobileResEnvelopeModel at line 1

Here is my request and response

My Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.router.ees.com/">

<soapenv:Header/>

<soapenv:Body>

<web:verifyMobile>

<arg0>12345678</arg0>

</web:verifyMobile>

</soapenv:Body>

</soapenv:Envelope>

My Response

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<ns1:verifyMobileResponse xmlns:ns1="http://webservice.router.ees.com/">

<return>name</return>

</ns1:verifyMobileResponse>

</soap:Body>

</soap:Envelope>

VerifyMobileResEnvelopeModel

@Root(name = "soap:Envelope")

@Namespace( prefix = "soap", reference = "http://schemas.xmlsoap.org/soap/envelope/")

public class VerifyMobileResEnvelopeModel {

@Element(name = "soap:Body", required = false)

private VerifyMobileResBodyModel verifyMobileResBodyModel;

public VerifyMobileResBodyModel getVerifyMobileResBodyModel() {

return verifyMobileResBodyModel;

}

public void setBody(VerifyMobileResBodyModel verifyMobileResBodyModel) {

this.verifyMobileResBodyModel = verifyMobileResBodyModel;

}

}

VerifyMobileResBodyModel

@Root(name = "soap:Body", strict = false)

public class VerifyMobileResBodyModel {

@Element(name = "ns1:verifyMobileResponse", required = false)

@Namespace(prefix = "ns1", reference = "http://webservice.router.ees.com/")

private VerifyMobileResDataModel verifyMobileResModel;

public VerifyMobileResDataModel getVerifyMobileResModel() {

return verifyMobileResModel;

}

public void setVerifyMobileResModel(VerifyMobileResDataModel verifyMobileResModel) {

this.verifyMobileResModel = verifyMobileResModel;

}

}

VerifyMobileResDataModel

@Root(name = "ns1:verifyMobileResponse", strict = false)

@Namespace(prefix = "ns1", reference = "http://webservice.router.ees.com/")

public class VerifyMobileResDataModel {

@Element(name = "return", required = false)

private String customerName;

public String getCustomerName() {

return customerName;

}

public void setCustomerName(String customerName) {

this.customerName = customerName;

}

}

Method

public void getResponse() {

VerifyMobileRqstDataModel mVerifyMobileRqstDataModel = new VerifyMobileRqstDataModel();

mVerifyMobileRqstDataModel.phoneNo = mobileNo;

VerifyMobileRqstBodyModel mVerifyMobileRqstBodyModel = new VerifyMobileRqstBodyModel();

mVerifyMobileRqstBodyModel.verifyMobileRqstDataModel = mVerifyMobileRqstDataModel;

VerifyMobileRqstEnvelopeModel mVerifyMobileRqstEnvelopeModel = new VerifyMobileRqstEnvelopeModel();

mVerifyMobileRqstEnvelopeModel.verifyMobileRqstBodyModel = mVerifyMobileRqstBodyModel;

Call<VerifyMobileResEnvelopeModel> call = webService.rqstVerifyMobileNo(mVerifyMobileRqstEnvelopeModel);

call.enqueue(new Callback<VerifyMobileResEnvelopeModel>() {

@Override

public void onResponse(Call<VerifyMobileResEnvelopeModel> call, Response<VerifyMobileResEnvelopeModel> response) {

if (response.isSuccessful() && response.body() != null) {

// String customerName = response.body().verifyMobileResBodyModel.verifyMobileResModel.customerName;

String customerName = response.body().getBody().getVerifyMobileResModel().getCustomerName();

Log.i("CustomerName", customerName);

}

}

@Override

public void onFailure(Call<VerifyMobileResEnvelopeModel> call, Throwable t) {

Log.e("Failure", t.getMessage());

}

});

}

I am facing some parsing issue. But getting the respone. In the method its not coming to response block, failure block get executed and it throws this exception. Its cumbersome to find out issue. I tried a lot. Please anyone help me. Thanks in advance.

Response in my code. But it didn't come inside the response block

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<ns1:verifyMobileResponse xmlns:ns1="http://webservice.router.ees.com/">

<return>Ramesh</return>

</ns1:verifyMobileResponse>

</soap:Body>

</soap:Envelope>

分享给朋友:
您可能感兴趣的文章:
随机阅读: