从.Net客户端调用Java webservice获取byte [](在Java上有示例)

时间:2011-09-01 15:38:34

标签: java .net wcf

我尝试使用.Net wcf客户端的java web服务器。在Visual Studio中,我生成SealingServicesClient。服务方法必须返回byte []

byte[] sealedDoc = File.ReadAllBytes(_SealedFileName);

using (var srv = new SealingServicesClient())
{
  srv.ClientCredentials.UserName.UserName = _User;
  srv.ClientCredentials.UserName.Password = _Pass;

  byte[] unsealedDoc = srv.Unseal(sealedDoc); // error
}

并收到此错误:

内容类型multipart / related; start =“”; type =“application / xop + xml”; boundary =“uuid:06ce2203-47e2-4d86-9b39-083a5b4a2e7a”; start-info =“text / xml”响应消息的内容与绑定的内容类型不匹配(text / xml; charset = utf-8)。如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前752个字节是:' - uuid:06ce2203-47e2-4d86-9b39-083a5b4a2e7a 内容ID: Content-Type:application / xop + xml; charset = utf-8; type =“text / xml” 内容传输编码:二进制

<?xml version ='1.0'coding ='UTF-8'?>< S:Envelope xmlns:S =“http://schemas.xmlsoap.org/soap/envelope/”>< ; S:正文>< ns4:UnsealResponse xmlns:ns5 =“http://xmlns.oracle.com/irm/system/wsdl” xmlns:ns4 =“http://xmlns.oracle.com/irm/content/wsdl”xmlns:ns3 =“http://xmlns.oracle.com/irm/content”xmlns:ns2 =“http:// xmlns .oracle.com / irm / core“>< return>< xop:Include xmlns:xop =”http://www.w3.org/2004/08/xop/include“href =”cid:a5946dbc- 02d2-4ab2-81d8-e272c7a12674@example.jaxws.sun.com“/>< /回报>< / NS4:UnsealResponse>< / S:身体与GT;< / S:信封>”

这是什么意思? 服务文档 和Java上的例子 http://download.oracle.com/docs/cd/E17904_01/user.1111/e12326/isvwscodesamples002.htm#BABJIBCE

感谢。

2 个答案:

答案 0 :(得分:1)

来自服务器的响应具有正确的信息,但.Net无法读取它。

回复

答案 1 :(得分:1)

看起来最外层的例外是掩盖最内层的异常,真实的异常。我遇到了同样的问题,这就是我的所作所为。

// I added this code to the catch block.
        catch (Exception ex)
        {
            // Get the most Innermost Exception so we can get to the root of the problem.
            while (ex.InnerException != null)
            {
                ex = ex.InnerException;
            }

            // Here I add some code to show the error. I did this way, you can do it whatever way you're most comfortable with.

            Console.WriteLine("Exception Message:");
            Console.WriteLine(ex.Message);
            Console.WriteLine("Exception Stacktrace:");
            Console.WriteLine(ex.StackTrace);
            Console.WriteLine("Exception Data:");
            Console.WriteLine(ex.Data);
            Console.WriteLine("Exception Source:");
            Console.WriteLine(ex.Source);
        }