简体   繁体   English

C# 服务客户端 - 传输编码:分块

[英]C# Service Client - Transfer-Encoding: Chunked

I'm currently trying to fix my SOAP-Client in C#, but got somehow stuck with the Transfer-Encoding.我目前正在尝试用 C# 修复我的 SOAP 客户端,但不知何故被传输编码卡住了。 I'm more or less a newbie to C#, so it's completly possible that im just missing something minor here.我或多或少是 C# 的新手,所以我完全有可能只是在这里遗漏了一些小东西。

I consumed a SOAP service from our local Tomcat Server following this: https://web.archive.org/web/20180506023052/http://www.csharptutorial.in/37/csharp-net-how-to-consume-a-web-service-in-csharp-net-visual-studio-2010我使用了本地 Tomcat 服务器的 SOAP 服务,如下所示: https : //web.archive.org/web/20180506023052/http : //www.csharptutorial.in/37/csharp-net-how-to-consume-a -web-service-in-csharp-net-visual-studio-2010

My current code:我目前的代码:

using System;
using ConsoleApp1.Lims;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            LimsZugriffService client = new LimsZugriffService();
           // FunktionsErgebnis response = client.connect();
           // Console.WriteLine("Connect" + response.meldung);
            String[] bond = new String[] { "versuch.auftrag.nr=2014/0031" };
            String[] bondFail = new String[] { "abc" };
            VersuchsschrittErgebnis reponseVersuch = client.ermittleVersuchsschritte(bond);
            Console.WriteLine(reponseVersuch.ermittelteVersuchsschritte.Length);
            Console.WriteLine(reponseVersuch.meldung);

        }
    }
}

After some testing I found out, that something does not work as intended.经过一些测试后,我发现有些东西不能按预期工作。 My Response-Array of <ermittelteVersuchsschritte> seems to be empty, while the "control"-Flags are parsed normally.我的<ermittelteVersuchsschritte>响应数组似乎是空的,而“控制”-Flags 被正常解析。

I captured the traffic between client and server to figure out what was wrong and it was actually completly there.我捕获了客户端和服务器之间的流量以找出问题所在,它实际上完全存在。 Just chunked into 8192 Byte blocks.只是分成 8192 字节块。

Could it be, that the C# implementation of the WebClient got some problems with Transfer-Encoding: Chunked ?难道是,WebClient 的 C# 实现在Transfer-Encoding: Chunked方面遇到了一些问题?

After googling for some hours i could not find a satisfiying solution to this issue.在谷歌搜索了几个小时后,我找不到一个令人满意的解决方案来解决这个问题。 I hope somebody, who knows C# and WebServices better than me has the answer.我希望比我更了解 C# 和 WebServices 的人有答案。

For the sake of completeness:为了完整起见:

My WSDL我的WSDL

My Traffic - Request->Response我的流量 - 请求 - >响应

After some researching, trial and error and much time I finally figured out my mistake.经过一些研究,反复试验和很多时间,我终于弄清楚了我的错误。

C# seems not to have a problem with the Transfer-Encoding: Chunked C# 的Transfer-Encoding: Chunked似乎没有问题

The mistake was on the service side.错误是在服务方面。 The consumed wsdl was generated from java code with the help of Axis (the first Axis not Axis2 ).消耗的wsdl是在Axis (第一个Axis不是Axis2 )的帮助下从 java 代码生成的。 Axis generated a wsdl 1.0 while C# seems to expect wsdl 2.0 . Axis 生成了wsdl 1.0而 C# 似乎期望wsdl 2.0 So in the end, the XML-structure described in the wsdl was flawed and could not be automatically consumed.所以最终, wsdl中描述的 XML 结构存在缺陷,无法自动使用。

We fixed this problem by switching from Axis to Apache CXF .我们通过从Axis切换到Apache CXF解决了这个问题。 The newly generated wsdl was than consumed without a problem at our C# - client side.新生成的wsdl在我们的 C# 客户端没有问题地被使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM