如何使用MTOM使用WSE 3.0发送文件? [英] How to Send File with WSE 3.0 using MTOM?

查看:87
本文介绍了如何使用MTOM使用WSE 3.0发送文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有WSE 3.0的ASP.NET在Visual Studio 2005中创建了一个Web服务,我的一种方法是使用MTOM从Web服务器向客户端发送文件。 WSE 3.0设置似乎没问题。结果我得到base64-code(byte),但我需要的是将文件作为附件。可悲的是,我无法找到解决方案。我在网上看到了很多例子,但我没有成功。我希望在这里找到一些帮助。我正在使用soapUI(www.soapui.org)测试我的网络服务。

这是我从网络方法得到的结果:

HTTP / 1.1 200 OK
服务器:Microsoft-IIS / 5.1
日期:2009年8月19日星期三13:33:27 GMT
X-Powered-By:ASP.NET
X-AspNet-Version:2.0.50727
Cache-Control:private,max-age = 0
Content-Type:application / soap + xml; charset = utf-8
内容长度:39248

<?xml version =" 1.0" encoding =" utf-8"?>< soap:Envelope xmlns:soap =" http://www.w3.org/2003/05/soap-envelope"的xmlns:的xsi = QUOT; HTTP://www.w3.org/2001/XMLSchema-instance"的xmlns:XSD = QUOT; HTTP://www.w3.org/2001/XMLSchema"的xmlns:WSA = QUOT; HTTP://schemas.xmlsoap.org/ws/2004/08/addressing"的xmlns:的wsse = QUOT; HTTP://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu =" http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">< env:Header xmlns:env =" ; HTTP://www.w3.org/2003/05/soap-envelope">< WSA:作用> HTTP://test.de/2009/ws/test/GetFileResponse< / WSA:作用>< WSA:邮件ID>瓮:UUID:0545eb3c-631C-4738-bb3c-ef1c1c79d39d< / WSA:邮件ID>< WSA:RelatesTo>瓮:UUID:c01b6eeb-de06-4037-b608-5b198f4a399c< / WSA:RelatesTo>< wsa:To> http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous< / wsa:To>< wsse:Security>< wsu:Timestamp wsu:Id =" Timestamp- f0132c3b-9ed8-4883-824c-60eecaf2d7b0">< WSU:创建> 2009-08-19T13:33:28Z< / WSU:创建>< WSU:过期> 2009-08-19T13:38:28Z< / wsu:Expires>< / wsu:Timestamp>< / wsse:Security>< / env:Header>< soap:Body>< GetFileResponse xmlns =" http://test.de/2009/ws/ test">< GetFileResult>

***** BASE 64 ******

< / GetFileResult>< / GetFileResponse>< / soap:Body>< / soap:Envelope>

这是我的webmethod代码:


< WebMethod( )> _
公共函数GetFile(ByVal filename As String)As Byte()
Dim response As Byte()
Dim filePath As String = AppDomain.CurrentDomain.BaseDirectory +" App_Data \" + filename
response = File.ReadAllBytes(filePath)
返回响应
结束功能

如何将base64(byte)作为这种格式的附件:< xop:include> ??? Content-Type设置为application / soap + xml,但我需要application / xop + xml。

请帮帮我!谢谢!

解决方案

只是为了确保:你知道WSE已经过时了吗?请参阅 WSE已过时 - 仅在必要时使用。

I have created a web service in Visual Studio 2005 with ASP.NET with WSE 3.0 and one of my methods is sending a file from the webserver to the Client using MTOM. The WSE 3.0 settings seems to be ok. As a result I get the base64-code (byte), but what I need is to get the file as an attachment. Sadly I'm not able to find a solution. I have seen a lot of examples in the web, but I was not successfully. I hope to find here some help. I'm testing my web service using soapUI (www.soapui.org).

This is the result I get from the webmethod:

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 19 Aug 2009 13:33:27 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 39248

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope"><wsa:Action>http://test.de/2009/ws/test/GetFileResponse</wsa:Action><wsa:MessageID>urn:uuid:0545eb3c-631c-4738-bb3c-ef1c1c79d39d</wsa:MessageID><wsa:RelatesTo>urn:uuid:c01b6eeb-de06-4037-b608-5b198f4a399c</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsse:Security><wsu:Timestamp wsu:Id="Timestamp-f0132c3b-9ed8-4883-824c-60eecaf2d7b0"><wsu:Created>2009-08-19T13:33:28Z</wsu:Created><wsu:Expires>2009-08-19T13:38:28Z</wsu:Expires></wsu:Timestamp></wsse:Security></env:Header><soap:Body><GetFileResponse xmlns="http://test.de/2009/ws/test"><GetFileResult>

*****BASE 64******

</GetFileResult></GetFileResponse></soap:Body></soap:Envelope>

This is my webmethod code:


    <WebMethod()> _
Public Function GetFile(ByVal filename As String) As Byte()
        Dim response As Byte()
        Dim filePath As String = AppDomain.CurrentDomain.BaseDirectory + "App_Data\" + filename
        response = File.ReadAllBytes(filePath)
        Return response
    End Function


How is that possible to get the base64 (byte) as an attachment in this format: <xop:include> ??? The Content-Type is set to application/soap + xml, but I need application/xop + xml.

Please help me! Thank you!

解决方案

Just to make sure: are you aware that WSE is obsolete? See WSE is Obsolete - Use Only If Necessary.


这篇关于如何使用MTOM使用WSE 3.0发送文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆