如何从Web服务的响应中解析数据 [英] How to parse data from the response from webservice
问题描述
你好朋友,我想从响应流中创建自定义类型.我先说清楚.
我必须从mstrAPIURL = http://www.example.com?e = {0}(任意url)中获取数据.为此我用了
以下代码
字符串str = string.Empty;
var client = new WebClient();
StreamData = client.OpenRead(mstrAPIURL);
如果(StreamData!= null)
{
var reader = new StreamReader(StreamData);
str = reader.ReadLine();
}
在str变量m中获取响应resultCode = 7000&resultDesc = SucessFull
并且响应格式是固定的.我想创建具有属性resultCode和resultDesc的类.我不想执行字符串操作
Hello friend , i want to create custom type from the response stream . Let me clear first.
from mstrAPIURL=http://www.example.com?e={0}(arbitary url) i have to fetch data. for this i have used
following code
string str = string.Empty;
var client = new WebClient();
StreamData = client.OpenRead(mstrAPIURL);
if (StreamData != null)
{
var reader = new StreamReader(StreamData);
str = reader.ReadLine();
}
in the str variable m getting response resultCode=7000&resultDesc=SucessFull
and the response format is fixed. i want to can i create class with properties resultCode and resultDesc. i don want to do string manipulation
推荐答案
错误自言自语-取消授权请求".
您正在将无效的凭据传递到HTTP/REST调用,而相应的REST服务/应用程序拒绝了该凭据.验证要传递给REST呼叫/服务的凭据.
如果相应的REST服务/应用程序是您开发的范围,那么您可以查看下面的技巧/窍门"以使用" Fiddler "对其进行调试.
调试WCF REST服务.
As the error speaks it self - "Un-Authorize Request".
You are passing invalid credentials to your HTTP/REST call which are refused by corresponding REST Service/Application. Verify the credentials which you are passing to your REST Call/Service.
If corresponding REST Service/Application is in-scope of your development then you may have a look at my below Tip/Trick to debug it using "Fiddler".
Debug WCF REST Service.
这篇关于如何从Web服务的响应中解析数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!