开发者

Call Java webservice from .Net client to get byte[] (have example on Java)

I try to use java web server from .Net wcf client. In Visual Studio I generate SealingServicesClient. The service method must return 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
}

And get this error:

The content type multipart/related;start="";type="application/xop+xml";boundary="uuid:06ce2203-47e2-4d86-9b39-083a5b4a2e7a";start-info="text/xml" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 752 bytes of the response were: '--uuid:06ce2203-47e2-4d86-9b39-083a5b4a2e7a Content-Id: Content-Type: applica开发者_如何学运维tion/xop+xml;charset=utf-8;type="text/xml" Content-Transfer-Encoding: binary

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><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"/></return></ns4:UnsealResponse></S:Body></S:Envelope>'.

What does it mean? Service documentation and example on Java http://download.oracle.com/docs/cd/E17904_01/user.1111/e12326/isvwscodesamples002.htm#BABJIBCE

Thanks.


The responce from the server have right info, but .Net can't read it.

the responce

HTTP/1.1 200 OK
Date: Fri, 02 Sep 2011 09:43:18 GMT
Content-Type: multipart/related;start="<rootpart*979851cd-ff15-4035-9318-2c4215cd1139@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:979851cd-ff15-4035-    9318-2c4215cd1139";start-info="text/xml"
Set-Cookie: JSESSIONID=fHlqTglWg23LF2tLwyfGXG2HGgn1bHKyPpb10vJj4dWxYJp6cQMY!-720077047; path=/; 
HttpOnly
X-ORACLE-DMS-ECID: 0000J8dXLpr4ioWzLwfP8A1ENZBP0000__
X-Powered-By: Servlet/2.5 JSP/2.1
Content-Length: 20965

--uuid:979851cd-ff15-4035-9318-2c4215cd1139
Content-Id: <rootpart*979851cd-ff15-4035-9318-2c4215cd1139@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version='1.0' encoding='UTF-8'?><S:Envelope 
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><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:99c1dae5-107c-4819-b740-
1c12427bf6c0@example.jaxws.sun.com"/></return></ns4:UnsealResponse></S:Body></S:Envelope>
--uuid:979851cd-ff15-4035-9318-2c4215cd1139
Content-Id: <99c1dae5-107c-4819-b740-1c12427bf6c0@example.jaxws.sun.com>
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

????????????????????>????
(cut binary data)
--uuid:979851cd-ff15-4035-9318-2c4215cd1139--


It looks like the outermost exception is masking the innermost one, the real one. I had the same problem and here's what I did.

// 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);
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜