zoukankan      html  css  js  c++  java
  • SoapUI 设置 request data with json body

    --背景

    使用WCF定义REST风格的WebService,如下:

        [ServiceContract]
        public interface INISTService
        {
            [OperationContract, WebInvoke(UriTemplate = "/EnrollTP/{context}",
                RequestFormat = WebMessageFormat.Json,
                ResponseFormat = WebMessageFormat.Json,
                Method = "POST",
                BodyStyle = WebMessageBodyStyle.Bare)]
            bool Enroll(string packageStr, string context);
           
        }

    --编写测试代码

    由于参数“packageStr”的内容过大超过URI的限定长度,需要将其放入Request对象中,在自己编写客户端代码测试时,将packageStr的值转为BASE64STRING放入参数sendData中,并将其存入到HTTPWebRequest对象中。

    HttpWebRequest webRequest = HttpWebRequest.Create(uri) as HttpWebRequest;
                    webRequest.Method = "POST";
                    webRequest.Accept = AcceptHeader;
                    webRequest.ContentType = ContentType;
                    if (timeOut != 0)
                        webRequest.Timeout = timeOut;
                    Stream stream = webRequest.GetRequestStream();
                    using (StreamWriter writer = new StreamWriter(stream))
                    {
                        writer.Write(sendData);
                    }

    --使用SoapUI时,按照接口定义设置request data为JSON类型(copy BASE64STRING into),如图

  • 相关阅读:
    ios原生项目内嵌u3d工程
    u3d内嵌H5游戏 设置cookie
    unity3d IL2CPP for android
    unity3D内嵌android项目
    Django 跨域问题
    tensorflow 调试tfdbg
    Cuda9.1+cunn7.1+Tensorflow1.7-GUP
    shader
    lua 中protobuf repeated 嵌套类 复合类型
    30岁的思考
  • 原文地址:https://www.cnblogs.com/atuotuo/p/5457451.html
Copyright © 2011-2022 走看看