ews soap请求在updateitem上失败

oyjwcjzk  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(263)

我想知道如何通过java/groovy脚本发布以下请求:
已发送soap请求(大小:1232)

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <RequestServerVersion xmlns="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2013_SP1"></RequestServerVersion>
  </soap:Header>
  <soap:Body>
    <UpdateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" MessageDisposition="SaveOnly" ConflictResolution="AutoResolve">
      <ItemChanges>
        <t:ItemChange xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
          <t:ItemId Id="AAMkADVmY2M3YTNmLTRmNTAtNDgxOS05N2ZhLWMyNTc0YWZlMDhlNwBGAAAAAAAQBgKUNgxZT6CYzuo2SsPlBwDW6sia8LrPRrmNln3i877OAAAAAAEMAAAT3G5bCC7PSJ3ZbmUh540OAACBI4lIAAA=" ChangeKey="CQAAABYAAAAT3G5bCC7PSJ3ZbmUh540OAACBK17k"></t:ItemId>
          <t:Updates>
            <t:SetItemField>
              <t:FieldURI FieldURI="item:Categories"></t:FieldURI>
              <t:Message>
                <t:Categories>
                  <t:String>ÁÉÍÓÖÚÜ</t:String>
                </t:Categories>
              </t:Message>
            </t:SetItemField>
          </t:Updates>
        </t:ItemChange>
      </ItemChanges>
    </UpdateItem>
  </soap:Body>
</soap:Envelope>

http/1.1 500内部服务器错误

Server: Microsoft-IIS/7.5.
  request-id: 9baa3ecb-99c1-42a9-98b6-1b5b74af4c9d.
  X-AspNet-Version: 4.0.30319.
  Cache-Control: private.
  Content-Type: text/xml; charset=utf-8.
  Date: Fri, 11 Dec 2020 01:49:20 GMT.
  Transfer-Encoding: chunked.
  Persistent-Auth: true.
  Connection: close.
  Set-Cookie: exchangecookie=7fe34835e0d84ccaaa4bafdbd70b424a; expires=Sat, 11-Dec-2021 01:49:20 GMT; path=/; HttpOnly.
  Set-Cookie: X-BackEndCookie=S-1-5-21-1275210071-2000478354-682003330-2272537=u56Lnp2ejJqBnZmdyZ7MyM/SmcvIyNLLysaa0p6dm5zSyMnIzs7GyJmeyJyagYHNz83O0s/O0s7Pq8/OxcvGxc3P; expires=Sun, 10-Jan-2021 01:49:20 GMT; path=/ews; secure; HttpOnly.
  X-Powered-By: ASP.NET.

同样的请求在使用sope时也可以正常工作。同样的请求通过罚款发送时,没有特别重音字符。我试着对字符进行编码,但没有用。

42fyovps

42fyovps1#

找到了一个有效的方法:

static String escapeSpecialChars(String inputData){ 
    def value = inputData.toString();
    Pattern p = Pattern.compile('[^#|()-_&\'"!. A-Za-z0-9]');
    Matcher m = p.matcher(value);
    boolean b = m.find();
     if (b == true){

            def input = value;
            def output=''
            for(int l=0;l<input.length();l++){
                char temp = input.getAt(l);
                int ascii = temp
                boolean check = p.matcher(temp.toString());
                if(check == true){
                 output += '&#'+ascii+';';
                 println '&#'+ascii+';'
                }else{
                    output += temp;
                }

            }
            value = output;
    }
    inputData = value;
    return inputData; }

但一个更优雅的解决方案可能是在cdata中 Package 类别,如:

cat = cat ==~ /[#|()-_&\'\"!. A-Za-z0-9]*/ ? "$cat" : "<![CDATA[$cat]]>"

相关问题