[英]could not get response for webservice even in postman
iam implementing .svc web services but could not get success in response . iam实现.svc Web服务,但响应失败。 Please let me know the issue 请让我知道这个问题
web service url is : http://77.92.177.131/Focus8Library/TransactionService.svc/LoadVoucher Web服务网址是:http: //77.92.177.131/Focus8Library/TransactionService.svc/LoadVoucher
and we have to send json input : 并且我们必须发送json输入:
json is : json是:
"{
""iVoucherType"": 5635,
""sVoucherNo"": ""101973"",
""objLoadTrans"": {
""arrBodyIds"": null,
""arrBodyNames"": [
""Product"",
""Description"",
""Unit"",
""Quantity"",
""L-Sales Quotations"",
""Rate"",
""Gross"",
""Discount Amt"",
""Discount %"",
""sRemarks""
],
""arrFooterIds"": null,
""arrFooterNames"": [
""Scheme Discount"",
""Round Off"",
""Card Charges"",
""Special Discount""
],
""arrHeaderIds"": null,
""arrHeaderNames"": [
""sVoucherNo"",
""Date"",
""CustomerAC"",
""Currency"",
""Outlet"",
""Salesman"",
""Cost Center"",
""sNarration"",
""Delivery_Address"",
""Delivery_Terms"",
""Pay_Terms"",
""LPONo""
]
},
""bByIds"": ""false""
}"
we have to send fsessionid - Should be added in the request header 我们必须发送fsessionid-应该添加到请求标头中
session id is :==>> 280520188522077721
I am using Volley JsonObjectRequest and my model is parsed with Gson library. 我正在使用Volley JsonObjectRequest,并且我的模型已用Gson库解析。 I have also implemented WCF webservice. 我还实现了WCF Web服务。
[WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "simplePostExample", BodyStyle = WebMessageBodyStyle.Bare)]
Test simplePostExample(Test test);
Test is custom object. 测试是自定义对象。
it is working perfectly in my scenario. 在我的情况下,它运行良好。
public class CustomJsonRequest extends JsonRequest<T> {
private Class<T> mType;
private String mEncodedCharSetProtocol = "utf-8";
CustomJsonRequest(int method, String url, Class<T> type, JSONObject jsonRequest,
Response.Listener<T> listener, Response.ErrorListener errorListener) {
super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener,
errorListener);
this.mType = type;
}
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
try {
String parsed;
try {
if (mEncodedCharSetProtocol != null) {
parsed = new String(response.data, mEncodedCharSetProtocol);
} else {
parsed = new String(response.data,
HttpHeaderParser.parseCharset(response.headers));
}
} catch (UnsupportedEncodingException e) {
parsed = new String(response.data);
}
Gson gson = new Gson();
return Response.success(gson.fromJson(parsed, mType),HttpHeaderParser.parseCacheHeaders(response));
} catch (Throwable e) {
return Response.error(new ParseError(e));
}
}
}
Also include Gson library 还包括Gson库
implementation 'com.google.code.gson:gson:2.8.2'
I hope it will work. 我希望它能起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.