小编hfr*_*713的帖子

XML文档(1,2)中存在错误,System.InvalidOperationException:<AuthorizationResult xlms:"">未被预期

从API发送的XML

<AuthenticationResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<PAPIErrorCode>0</PAPIErrorCode>
<ErrorMessage/>
<AccessToken>StringAccessToken</AccessToken>
<AccessSecret>StringAccessToken</AccessSecret>
<PolarisUserID>PolarisSampleUser</PolarisUserID>
<BranchID>7</BranchID>
<AuthExpDate>2013-05-27T16:57:46.323</AuthExpDate>
</AuthenticationResult>
Run Code Online (Sandbox Code Playgroud)

响应类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace PAPIAutomatedTestingTool
{
    [XmlRoot(ElementName="AuthorizationResult")]
    public class AuthorizationResult
    {
        public int PAPIErrorCode { get; set; }

        public string ErrorMessage { get; set; }

        public string AccessToken { get; set; }

        public string AccessSecret { get; set; }

        public int PolarisUserID { get; set; }

        public int BranchID { get; set; }

        public DateTime …
Run Code Online (Sandbox Code Playgroud)

c# xml api httpwebresponse deserialization

12
推荐指数
1
解决办法
5万
查看次数

包含内的正则表达式

我在c#工作,我正在尝试检查字符串的值{some value}.最重要的是,我正在寻找字符串是否包含{},其中介于两者之间.我在想reg-ex,但我真的不知道如何在String.Contains中实现它.我已经尝试创建一个reg-ex实例并将其传递给Contains但这似乎不起作用.如果有更简单的方法,请告诉我.

if (uri.Contains("{one word}"))
    {

    }
return false;
Run Code Online (Sandbox Code Playgroud)

这是我尝试过的,

public bool SimpleResponseCodeCheck(string callTested, string testName) 
{
    testParams = SupportingMethodsClass.ReturnXMLData(callTested, testName);
    string uri;
    string method;
    string requestBody;
    string expResponseCode;
    string actResponseCode;
    string statusMessage;
    string respBody;
    Regex testParameter = new Regex("\\{.+\\}");

    testParams.TryGetValue("uri", out uri);
    testParams.TryGetValue("method", out method);
    testParams.TryGetValue("expResponseCode", out expResponseCode);
    testParams.TryGetValue("requestBody", out requestBody);

    if (testParameter.IsMatch(uri, 0))
    {

    }
    return false;
}
Run Code Online (Sandbox Code Playgroud)

c# regex string contains

2
推荐指数
1
解决办法
131
查看次数

标签 统计

c# ×2

api ×1

contains ×1

deserialization ×1

httpwebresponse ×1

regex ×1

string ×1

xml ×1