Retrofit Frame Request SOAP WebService

Foreword:

Recently, Android uses the Retrofit framework to make network requests, which has become very popular, but online examples or existing request background servers are generally based on the Rest method, that is, the parameters sent when sending the request are generally directly placed in the header or path path, which is a bit more complicated Put the parameters in the form to request. If the background is based on the WebService method, the data format sent is SOAP-type XML data, and everyone generally uses the ksoap framework to request. If a client has two background services, using two network frameworks in the client code is generally not what you want. With the continuous update of the Retrofit framework, it should be the general trend for this framework to make network requests. However, using Retrofit to make Webservice requests, there are too few online resources. After searching for these two days, only two related documents and one demo were found:

Article 1: http://m.blog.csdn.net/article/details?id=51133893 This is a reprint written by a Taiwanese, only fragmentary code, without explaining the data assembly from beginning to end. There is no demo that can be run directly, nor did it clearly explain the different SOAP versions, and the requests are very different;

Article 2: http://m.blog.csdn.net/article/details?id=51163808 This is the author’s own practice, I have to say that it took a lot of effort, but the data assembly is not clear, nor is it shown Demo. And when the author sent the request, he passed the requested model directly as a string, which did not play out retrofit’s SimpleXmlConverterFactory The powerful advantage.

Example: The demo download address is https://github.com/asanchezyu/RetrofitSoapSample, I have to say, this is One can run a complete demo, but this is based on SOAP Version 1.2. For different SOAP versions, the request is still quite different. Moreover, there is no data in the author’s return, and the analysis return data cannot be seen.


Look I want to transfer back to the ksoap camp several times with this piece of information on the Internet. But as a developer, you can’t copy other people’s code all the time. Programmers who don’t use their brains are not good programmers. I was determined to use Retrofit to successfully request Webservice data. After two days of research, I finally paid off and successfully requested the data.


SOAP The Webservice testing tool general is based on the SoapUI tool. After importing the project, this tool can clearly view the methods included in the WebService, the SOAP version, and the request parameters of each method. You can also directly simulate network requests and view the returned results. The specific usage of SoapUI will not be mentioned here. The following is tested with the project http://www.webservicex.net/uszip.asmx?WSDL. The method included in the project is shown on the left, and the request is sent in the middle. xml package, on the right is the xml data returned by the server.


If you have successfully called the function, you can also use the Charles Packet Capture Tool to see the package of the requested data.

This is a screenshot of a successful request for webservice using the retrofit framework



The request body can be clearly viewed through the SoapUI tool, and the implementation will be easier. The following specifically talk about how to use Retrofit to implement SOAP WebService network requests.


Implementation:

1. SOAP version

Different SOAP versions require different namespaces. For details, you can use the SoapUI tool or ask the back-end developers to see the SoapEnvelop source code.



As can be seen from the above figure, the namespaces of 1.0, 1.1, 1.2 versions are somewhat different, This will affect subsequent requests for writing Envelope package encapsulation.


2. Preparatory work, because WebService data request and return are all in xml format, needImport the dependency package parsed by Retrofit xml (the three classes of stax|stax-api|xpp3 need to be excluded, otherwise an error will be reported during compilation)

compile("com.squareup.retrofit2:converter-simplexml:2.0.0 -beta3"){ exclude  module: 'stax'  < /strong>exclude module: 'stax-api ' exclude module: 'xpp3' }
 
3. Writing Retrofit request object, including request base address, request header Content-Type is set to text/xml;charset=UTF-8, converter is set to
SimpleXmlConverterFactory. 
[java] view plain copy

  1. /**
  2. * Server Retrofit variable initialization
  3. * Created by SmileXie on 16/7/16.
  4. < span class="comment">*/
  5. public span>classJXHDRetrofitGenerator{
  6. < /li>
  7. privatestatic Strategy strategy = newAnnotationStrategy();
  8. private span>staticSerializerserializer=newPersister( strategy);
  9. private< /span>static OkHttpClient.Builder okHttpClient=new OkHttpClient.Builder();
  10. privatestaticRetrofit.BuilderretrofitBuilder=new span>Retrofit.Builder()
  11. .addConverterFactory(SimpleXmlConverterFactory.create(serializer))
  12. >

  13. .baseUrl(Const ant.BASE_URL); //Requested webservice base address
  14. publicstatic S createService(ClassserviceClass){
  15. okHttpClient.interceptors().add(newInterceptor(){
  16. @Override /span>
  17. public okhttp3.Response intercept(Interceptor.Chain chain) span>throws IOException{
  18. Request original= chain.request();
  19. Request.Builder requestBuilder=original.newBuilder()
  20. .header(“Content-Type”,“text/xml;charset=UTF-8”)//Add request header
  21. .method( original.method(), original.body());
  22. Request request = requestBuilder .build();
  23. returnchain.proceed(request);
  24. < span>
  25. OkHttpClient client = okHttpClient.connectTimeout(2, TimeUnit.MINUTES)< /span>
  26. .writeTimeout(2, TimeUnit.MINUTES)< /li>
  27. .readTimeout(2, TimeUnit.MINUTES)
  28. .build();
  29. Retrofitretrofit=retrofitBuilder.client(client).build();
  30. return< /span>retrofit.create(serviceClass);
  31. }

4. Write request function
 
[java] view plain copy
  1. /**
  2. * Define the request Interface
  3. * Created by SmileXie on 16/7/15.
  4. */
  5. publicinterface JXHDInterfaceFun{
  6. @Headers({"SOAPAction:getRoleinfo" })//The requested Action, similar to the method name
  7. @POST("service?wsdl")//Requested address
  8. CallgetRoleInfo(@BodyRoleInfoRequestEnveloperequestEnvelope);
  9. }
5. Assembly request Request Model
The main assembly xml data is as follows: 
1) Assemble the outermost soapenv:Envelope. The request here involves the namespace. Different SOAP versions are different. The following is the SOAP1.1 version:
 
< strong>[java] view plain copy
  1. / **
  2. * Created by SmileXie on 16/7/15.
  3. */
  4. @Root(name="soapenv:Envelope")
  5. @NamespaceList({
  6. < span> @Namespace(reference="http://www.w3.org/2001/XMLSchema-instance ", prefix="xsi"),
  7. @Namespace(reference="http://www.w3.org /2 001/XMLSchema", prefix="xsd"),
  8. @Namespace(reference="http://schemas.xmlsoap.org/soap /encoding/", prefix="enc"),
  9. @Namespace(reference="http://schemas. xmlsoap.org/soap/envelope/", prefix="soapenv")
  10. })
  11. publicclass RoleInfoRequestEnvelope{
  12. @Element(name="soapenv:Body", required=false)
  13. public RoleInfoRequestBody body;
  14. @Element (name="soapenv:Header", required=false )
  15. public String aHeader;< /span>
  16. }
< span style="font-size:18px">If your server is SOAP1.2 version, the namespace should be written like this, the prefix can be defined by yourself, but it must correspond to the prefix in @Element.
 
[java] view plain copy
  1. @Root(name=" soap12:Envelope")
  2. @NamespaceList({ ​< /span>
  3. @Namespace(prefix="xsi", reference="http://www.w3.org/2001/XMLSchema-instance" ),
  4. @Namespace(prefix="xsd", reference="http://www.w3.org/2001/XMLSchema"), li>
  5. @Namespace(prefix="soap12" span>, reference="http://www.w3.org/2003/05/soap-envelope")
  6. })
< pre style="font-family:Menlo; background-color:rgb(255,255,255)">
2)Assemble the outermostBody part:< /span>
 
[java] view plain copy
  1. / **
  2. * User role returns to body
  3. * Created by SmileXie on 16/7/15.
  4. */
  5. @Root (name="soapenv:Body", strict=false )
  6. publicclass span> RoleInfoRequestBody{
  7. @Element(name= "getroleinfo", required=false)
  8. publicUserInfoBaseRequestgetroleinfo;
  9. }
< /span>

3) Assemble the getrolinfo part:

 
[java] view plain copy
  1. /**
  2. * User information
  3. * Created by SmileXie on 16/7/15.< /span>
  4. */
  5. publicclassUserInfoBaseRequest{< /span>
  6. @Element( name="token", required=false)) span>
  7. public String token; li>
  8. @Element(name="userId")
  9. public String userid;
  10. @Element(name="userType")
  11. publicString userType;
  12. span>
  13. public String getToken(){
  14. returntoken;
  15. span>
  16. }

So far, the Request part is assembled. All request variables can be written as private, and then assigned with the setter method. Because there is no data modification involved, the author uses all public.

< pre style="font-family:Menlo; background-color:rgb(255,255,255)">

6. Write request Response Model
If you don’t know the format of the returned data in advance, you can skip writing this part first, and use ResponseBody to receive the returned data directly. Use the packet capture tool to check the Response part to get the returned result of the data, and then write it. 
< /pre>
The received data format is the same as that of the Request Model, which is parsed layer by layer . Retrofit uses SAX parsing by default, so every label needs to be parsed, or it will not report an error. 

< pre style="font-family:Menlo; background-color:rgb(255,255,255)">1) parse the outermost soapevn:Envelope

 
< strong>[java] view plain copy
    < li class="alt">/**
  1. * User role Return to general information
  2. * Created by SmileXie on 16/7/15.< /span>
  3. */
  4. @Root(na me="soapenv:Envelope")
  5. @NamespaceList({
  6. @Namespace(reference="http://www.w3.org/2001/XMLSchema-instance", prefix= "xsi"),
  7. @Namespace span>(reference="http://www.w3.org/2001/XMLSchema", prefix=< span class="string">"xsd"),
  8. @Namespace(reference="http://schemas.xmlsoap.org/soap/encoding/",prefix= "enc"),
  9. @Namespace(reference="http://schemas.xmlsoap.org/soap/envelope/" ,Prefix="soapenv")
  10. } )
  11. publicclass RoleInfoResponseEnvelope{
  12. @Element(name= "Body")
  13. public RoleInfoResponseBody body;
  14. } li>

2) Parse soapenv:Body part

 
[java]< /strong> view plain copy
  1. /**
  2. * User role returns to body
  3. * Created by SmileXie on 16/7/15.
  4. */
  5. @Root(name="Body")
  6. publicclassRoleInfoResponseBody{< /span>
  7. < /li>
  8. @Element(name="getroleinfoResponse", required=false)
  9. public RoleInfoResponse roleInfoResponse;
  10. }
3)Analysis

span>getroleinfoResponsepart

 
[java] view pla in copy
  1. /**
  2. * User role return< /li>
  3. * Created by SmileXie on 16/7/15.
  4. */
  5. < li>@Root(name="getroleinfoResponse") span>
  6. @NamespaceList({
  7.         @Namespace(reference = "http://www.w3.org /2001/XMLSchema-instance", prefix = "xsi"< /span>),  
  8.         @Namespace(reference = "http://www.w3.org/2001/XMLSchema", prefix = "xsd"),  
  9.         @Namespace(reference = "http://schemas.xmlsoap.org/soap/encoding/", prefix = "enc"),  
  10.         @Namespace(reference = "http://schemas.xmlsoap.org/soap/envelope", prefix = "env"),  
  11.         @Namespace(reference = "http://schemas.xmlsoap.org/soap/encoding/", prefix = "encodingStyle"),  
  12. })  
  13. public class RoleInfoResponse {  
  14.     @Attribute(name = "encodingStyle")  
  15.     public String encodingStyle;  
  16.   
  17.   
  18.     @Element(name = "getroleinfoReturn")  
  19.     public RoleInfoResponseReturn reolInfo;  
  20.   
  21. }  
4)解析最里一层,getroleinfoReturn部分
            
[java] view plain copy
  1. /** 
  2.  * 用户角色返回 
  3.  * Created by SmileXie on 16/7/18. 
  4.  */  
  5.   
  6. @Root(name = "getroleinfoReturn")  
  7. @Namespace(reference = "http://www.w3.org/2001/XMLSchema-instance", prefix = "xsi")  
  8. public class RoleInfoResponseReturn {  
  9.     @Attribute(name = "type")  
  10.     public String xsiType;  
  11.   
  12.     @Text()  
  13.     public String message;  
  14.   
  15. }  
最里边的数据其实是String型,直接用@Text注解获取,我们这里返回的是一个json,最后转用Gson来解析的。
7. 编写请求代码
[java] view plain copy

  1. private void testSOAP() {  
  2.         JXHDInterfaceFun apiService = JXHDRetrofitGenerator.createService(JXHDInterfaceFun.class);  
  3.         RoleInfoRequestEnvelope requestEnvelope = new RoleInfoRequestEnvelope();    //soapenv:Envelope  
  4.         RoleInfoRequestBody requestBody = new RoleInfoRequestBody();    // body  
  5.         UserInfoBaseRequest baseRequest = new UserInfoBaseRequest();    // getroleinfo  
  6.         baseRequest.userid = "liliting";  
  7.         baseRequest.userType = "2";  
  8.         requestBody.getroleinfo = baseRequest;  
  9.         request Envelope.body = requestBody;  
  10.   
  11.         Call call = apiService.getRoleInfo(requestEnvelope);  
  12.         call.enqueue(new Callback() {  
  13.             @Override  
  14.             public void onResponse(Response response) {  
  15.                 Util.stopProgressDialog();  
  16.                 RoleInfoResponseEnvelope roleInfoResponseEnvelope = response.body();  
  17.                 if (roleInfoResponseEnvelope != null ) {  
  18.                     String message = roleInfoResponseEnvelope.body.roleInfoResponse.reolInfo.message;  
  19.                     BaseResponse baseResponse = GsonUtil.getJsonObject(message, BaseResponse.class);  
  20.                     if(baseResponse != null) {  
  21.                         RoleInfoResponse roleResponse = GsonUtil.getJsonObject(baseResponse.getMessage(), RoleInfoResponse.class);  
  22.                         String roleType = roleResponse.getRoles();  
  23.                     }  
  24.   
  25.                 }  
  26.             }  
  27.             @Override  
  28.             public void onFailure(Throwable t) {  
  29.                 Util.stopProgressDialog();  
  30.                 Toast.makeText(SendMessageActivity.this, getString(R.string.load_fail), Toast.LENGTH_SHORT).show();  
  31.             }  
  32.         });  
  33.     }  


采用Retrofit进行WebServi ce请求,上面代码完整显示了请求数据的封装,返回数据的解析,请求函数的编写,Retrofit对象组装,请求代码等。稍候我会把在项目实施中遇到的一些问题进行总结,并把相应代码整理成demo,供大家参考。 
后记:
两种框架对比:
用Retrofit进行WebService请求,在组装请求数据时,需要进行Envelop,Body,RequestMode的组装,至少要用到3个类;
在解析返回的XML数据时,也要进行Envelop,Body,ResponseModel的解析,至少需要用3个类。 
这样Retrofit框架比ksoap框架进行WebService请求,类变多了,但并没有变麻烦。这样写使整个请示都清晰了,开发者可以清楚看到数据的组装。 
用ksoap请求,请求头公共的,可以写在一起,请求的对象只需要通过HashMap传值过去,ksoap会相应的组装body部分;
返回的对象解析只需要用到一个类,比WebService编写简单。 
但ksoap需要单独写个AsyncTask来进行网络请求,而Retrofit包含了同步和异步请求框架,不用开发者单独写线程请求。 
且Retrofit结合RxJava,现在变得越来越流行起来。 
具体大家如何决择,还得具体情况具体分析。 
--------------------我是华丽的分隔线-----------------------
这两天写了个demo,利用Retrofit网络框架进行WebService SOAP1.1请求,以请求天气预报为例,天气预报的请求网址为:
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?op=getWeatherbyCityName
这里边也很详情的说明了SOAP1.1和SOAP1.2请求model和返回mo del的数据格式。 
工程下载地址为:
https://github.com/xiewenfeng/RetorfitWebServiceSample


转自:http://blog.csdn.net/smileiam/article/details/51957232

[java] view plain copy

  1. /** 
  2.  * 服务器Retrofit变量初始化 
  3.  * Created by SmileXie on 16/7/16. 
  4.  */  
  5. public class< /span> JXHDRetrofitGenerator {  
  6.   
  7.     private static Strategy strategy = new AnnotationStrategy();  
  8.     private static Serializer serializer = new Persister(strategy);  
  9.   
  10.     private static OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder();  
  11.   
  12.    private static Retrofit.Builder retrofitBuilder =  new Retrofit.Builder()  
  13.             .addConverterFactory(SimpleXmlConverterFactory.create(serializer))  
  14.             .baseUrl(Constant.BASE_URL); //请求的webservice基址  
  15.   
  16.     public static  S createService(Class serviceClass) {  
  17.         okHttpClient.interceptors().add(new Interceptor() {  
  18.             @Override  
  19.             public okhttp3.Response intercept(Interceptor.Chain chain) throws IOException {  
  20.                 Request original = chain.request();  
  21.   
  22.                 Request.Builder requestBuilder = original.newBuilder()  
  23.                         .header(“Content-Type”“text/xml;charset=UTF-8”)//添加请求头  
  24.                         .method(original.method(), original.body());  
  25.   
  26.                 Request request = requestBuilder.build();  
  27.                 return chain.proceed(request);  
  28.             }  
  29.         });  
  30.   
  31.         OkHttpClient client = okHttpClient.connectTimeout(2, TimeUnit. MINUTES)  
  32.                 .writeTimeout(2, TimeUnit.MINUTES)  
  33.                 .readTimeout(2, TimeUnit.MINUTES)  
  34.                 .build();  
  35.         Retrofit retrofit = retrofitBuilder.client(client).build();  
  36.         return retrofit.create(serviceClass);  
  37.     }  
  38. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /** 
  2.  * 定义请求接口 
  3.  * Created by SmileXie on 16/7/15. 
  4.  */  
  5. public interface JXHDInterfaceFun {  
  6.     @Headers({“SOAPAction: getRoleinfo”})//请求的Action,类似于方法名  
  7.     @POST(“service?wsdl”)//请求的地址  
  8.     Call getRoleInfo(@Body RoleIn foRequestEnvelope requestEnvelope);  
  9. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /** 
  2.  * Created by SmileXie on 16/7/15. 
  3.  */  
  4. @Root(name = “soapenv:Envelope”)  
  5. @NamespaceList( {  
  6.         @Namespace(reference = “http://www.w3.org/2001/XMLSchema-instance”, prefix = “xsi”),  
  7.         @Namespace(reference = “http://www.w3.org/2001/XMLSchema”, prefix = “xsd”),  
  8.         @Namespace(reference = “http://schemas.xmlsoap.org/soap/encoding/”, prefix = “enc”),  
  9.         @Namespace(reference = “http://schemas.xmlsoap.org/soap/envelope/”, prefix = “soapenv “)  
  10. })  
  11. public class RoleInfoRequestEnvelope {  
  12.     @Element(name = “soapenv:Body”, required = false)  
  13.     public RoleInfoRequestBody body;  
  14.   
  15.     @Element(name = “soapenv:Header”, required = false)  
  16.     public String aHeader;  
  17.   
  18. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. @Root(name = “soap12:Envelope”)  
  2. @NamespaceList({  
  3.         @Namespace( prefix = “xsi”, reference = “http://www.w3.org/2001/XMLSchema-instance”),  
  4.         @Namespace( prefix = “xsd”, reference = “http://www.w3.org/2001/XMLSchema”),  
  5.         @Namespace( prefix = “soap12”, reference = “http://www.w3.org/2003/05/soap-envelope”)  
  6. })  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /** 
  2.  * 用户角色返回body 
  3.  * Created by SmileXie on 16/7/15. 
  4.  */  
  5. @Root(name = “soapenv:Body”, strict = false)  
  6. public class RoleInfoRequestBody {  
  7.     @Element(name = “getroleinfo”, required = false)  
  8.     public UserInfoBaseRequest getroleinfo;  
  9. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /** 
  2.  * 用户信息 
  3.  * Created by SmileXie on 16/7/15. 
  4.  */  
  5.   
  6. public class UserInfoBaseRequest {  
  7.   
  8.     @Element (name = “token”, required = false)  
  9.     public String token;  
  10.   
  11.     @Element(name = “userId”)  
  12.     public String userid;  
  13.   
  14.     @Element(name = “userType”)  
  15.     public String userType;  
  16.   
  17.     public String getToken() {  
  18.         return token;  
  19.     }  
  20.   
  21. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /** 
  2.  * 用户角色返回总信息 
  3.  * Created by SmileXie on 16/7/15. 
  4.  */  
  5. @R oot(name = “soapenv:Envelope”)  
  6. @NamespaceList({  
  7.         @Namespace(reference = “http://www.w3.org/2001/XMLSchema-instance”, prefix = “xsi”),  
  8.         @Namespace(reference = “http://www.w3.org/2001/XMLSchema”, prefix = “xsd”),  
  9.         @Namespace(reference = “http://schemas.xmlsoap.org/soap/encoding/”, prefix = “enc”),  
  10.         @Namespace(reference = “http://schemas.xmlsoap.org/soap/envelope/”, prefix = “soapenv”)  
  11. })  
  12. public class RoleInfoResponseEnvelope {  
  13.     @Element(name = “Body”)  
  14.     public RoleInfoResponseBody body;  
  15.   
  16. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /** 
  2.  * 用户角色返回body 
  3.  * Created by SmileXie on 16/7/15. 
  4.  */  
  5. @Root(name = “Body”)  
  6. public class RoleInfoResponseBody {  
  7.   
  8.     @Element(name = “getroleinfoResponse”, required = false)  
  9.     public RoleInfoResponse roleInfoResponse;  
  10.   
  11. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /** 
  2.  * 用户角色返回 
  3.  * Created by SmileXie on 16/7/15. 
  4.  */  < /span>
  5.   
  6. @Root(name = “getroleinfoResponse”)  
  7. @NamespaceList({  
  8.         @Namespace(reference = “http://www.w3.org/2001/XMLSchema-instance”, prefix = “xsi”),  
  9.         @Namespace(reference = “http://www.w3.org/2001/XMLSchema”, prefix = “xsd”),  
  10.         @Namespace(reference = “http://schemas.xmlsoap.org/soap/encoding/”, prefix = “enc”),  
  11.         @Namespace(reference = “http://schemas.xmlsoap.org/soap/envelope”, prefix = “env”),  
  12.         @Namespace(reference = “http://schemas.xmlsoap.org/soap/encoding/”, prefix = “encodingStyle”),  
  13. })  
  14. public class RoleInfoResponse {  
  15.     @Attribute(name = “encodingStyle”)  
  16.     public String encodingStyle;  
  17.   
  18.   
  19.     @Element(name = “getroleinfoReturn”)  
  20.     public RoleInfoResponseReturn reolInfo;  
  21.   
  22. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. /**  
  2.  * 用户角色返回 
  3.  * Created by SmileXie on 16/7/18. 
  4.  */  
  5.   
  6. @Root(name = “getroleinfoReturn”)  
  7. @Namespace(reference = “http://www.w3.org/2001/XMLSchema-instance”, prefix = “xsi”)  
  8. public class RoleInfoResponseReturn {  
  9.     @Attribute(name = “type”)  
  10.     public String xsiType;  
  11.   
  12.     @Text()  
  13.     public String message;  
  14.   
  15. }  

[java] view plain copy

[java] view plain copy

[java] view plain copy

  1. private void testSOAP() {  
  2.         JXHDInterfaceFun apiService = JXHDRetrofitGenerator.createService(JXHDInterfaceFun.class);  
  3.         RoleInfoRequestEnvelope requestEnvelope = new RoleInfoRequestEnvelope();    //soapenv:Envelope  
  4.         RoleInfoRequestBody requestBody = new RoleInfoRequestBody();    // body  
  5.         UserInfoBaseRequest baseRequest = new UserInfoBaseRequest();    // getroleinfo  
  6.         baseRequest.userid = “liliting”;  
  7.         baseRequest.userType = “2”;  
  8.         requestBody.getroleinfo = baseRequest;  
  9.         requestEnvelope.body = requestBody;  
  10.   
  11.         Call call = apiService.getRoleInfo(requestEnvelope);  
  12.         call.enqueue(new Callback() {  
  13.             @Override  
  14.             public void onResponse(Response response) {  
  15.                 Util.stopProgressDialog();  
  16.                 RoleInfoResponseE nvelope roleInfoResponseEnvelope = response.body();  
  17.                 if (roleInfoResponseEnvelope != null ) {  
  18.                     String message = roleInfoResponseEnvelope.body.roleInfoResponse.reolInfo.message;  
  19.                     BaseResponse baseResponse = GsonUtil.getJsonObject(message, BaseResponse.class);  
  20.                     if(baseResponse != null) {  
  21.                         RoleInfoResponse roleResponse = GsonUtil.getJsonObject(baseResponse.getMessage(), RoleInfoResponse.class);  
  22.                         String roleType = roleResponse.getRoles();  
  23.                     }  
  24.   
  25.                 }  
  26.             }  
  27.             @Override  
  28.             public void onFailure(Throwable t) {  
  29.                 Util.stopProgressDialog();  
  30.                 Toast.makeText(SendMessageActivity.this, getString(R.string.load_fail), Toast.LENGTH_SHORT).show();  
  31.             }  
  32.         });  
  33.     }  

[java] view plain copy

[java] view plain copy

Leave a Comment

Your email address will not be published.