社区
Web Services
帖子详情
客户端发现响应内容类型为“application/dime”,但应该是“text/xml”。到底是什么回事
sonkey
2006-04-11 11:51:21
我用程序调用一个带附件的wse2 webservice就出现:
客户端发现响应内容类型为“application/dime”,但应该是“text/xml”。请求失败,错误信息为: -- ))
请问怎么回事
...全文
524
14
打赏
收藏
客户端发现响应内容类型为“application/dime”,但应该是“text/xml”。到底是什么回事
我用程序调用一个带附件的wse2 webservice就出现: 客户端发现响应内容类型为“application/dime”,但应该是“text/xml”。请求失败,错误信息为: -- )) 请问怎么回事
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
14 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
AI魔法探索家|陈工聊AI
2006-04-12
打赏
举报
回复
添加WSE引用
添加Web引用
然后在解决方案管理器里
Web Reference文件夹下有两个代理文件
使用时要用 带WseAdv的那个
sonkey
2006-04-12
打赏
举报
回复
我都引用了,还是不行,晕,我基本上是按照wse2的帮助来做的。
然后导入WS引用 会添加2个引用文件
用的时候用Adv里面的
这两句话是什么意思啊?
adv是什么?
AI魔法探索家|陈工聊AI
2006-04-12
打赏
举报
回复
是不是Winform没添加WSE引用啊
项目上右键选WSE2.0Settings
钩上Enable WSE in this project
然后导入WS引用 会添加2个引用文件
用的时候用Adv里面的
sonkey
2006-04-12
打赏
举报
回复
我用winform程序就会出现
客户端发现响应内容类型为“application/dime”,但应该是“text/xml”。请求失败
用webform就不会出现。
AI魔法探索家|陈工聊AI
2006-04-12
打赏
举报
回复
客户端代码示例:
1 private void button2_Click(object sender, System.EventArgs e)
2 {
3 int offset = 0;
4 int buffersize = 3* 1024*1024;
5 bool bComplete = false;
6 FileStream fs = null;
7 string sFileName = textBox1.Text;
8 Adb.AdvWse adv = new TestWebSrv.Adb.AdvWse();
9 byte[] buffer = new byte[buffersize];
10 int size = 0;
11 int result = 0;
12 System.DateTime time = DateTime.Now;
13
14 while( !bComplete )
15 {
16 Application.DoEvents();
17 try
18 {
19 result = adv.GetPartitionAttachment(sFileName,offset,buffersize);
20 if (result == 0)
21 {
22 bComplete = true;
23 break;
24 }
25 if (adv.ResponseSoapContext.Attachments.Count != 0)
26 {
27 fs = new System.IO.FileStream(sFileName,FileMode.OpenOrCreate,FileAccess.Write);
28 fs.Seek(0,SeekOrigin.End);
29 size = adv.ResponseSoapContext.Attachments[0].Stream.Read(buffer,0,buffersize);
30 fs.Write(buffer,0,result);
31 offset += result;
32 textBox2.Text = offset.ToString()+"Bytes Received\r\n" + textBox2.Text;
33 Application.DoEvents();
34 }
35 else
36 {
37 bComplete = true;
38 break;
39 }
40 }
41 finally
42 {
43 fs.Close();
44 }
45
46 System.TimeSpan time1 = DateTime.Now - time;
47 this.Text = time1.ToString();
48 }
49
50
51 }
52
AI魔法探索家|陈工聊AI
2006-04-12
打赏
举报
回复
去年写的代码
绝对能用的
AI魔法探索家|陈工聊AI
2006-04-12
打赏
举报
回复
你的客户端添加WSE引用没?
sonkey
2006-04-12
打赏
举报
回复
楼上的方法也是同样的错误:
源错误:
行 71: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetPartitionAttachment", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
行 72: public int GetPartitionAttachment(string sFileName, int offset, int size) {
行 73: object[] results = this.Invoke("GetPartitionAttachment", new object[] {
行 74: sFileName,
行 75: offset,
源文件: e:\dkdsoft\wes_test\wse_web\web references\wse2\reference.cs 行: 73
堆栈跟踪:
[InvalidOperationException: 客户端发现响应内容类型为“application/dime”,但应该是“text/xml”。
请求失败,错误信息为:
--
))?uuid:e11edee1-6f1b-4a22-b68d-83538e9eb022http://schemas.xmlsoap.org/soap/envelope/<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/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/03/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"><soap:Header><wsa:Action>http://tempuri.org/GetPartitionAttachmentResponse</wsa:Action><wsa:MessageID>uuid:b946c99c-d087-48ae-b29c-cb96f77bc7be</wsa:MessageID><wsa:RelatesTo>uuid:3f8ac7f9-2cc9-4b88-adf4-c1c48182ba24</wsa:RelatesTo><wsa:To>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:To><wsse:Security><wsu:Timestamp wsu:Id="Timestamp-afd801be-05e5-4088-be0f-b496a2f6ae88"><wsu:Created>2006-04-12T01:35:50Z</wsu:Created><wsu:Expires>2006-04-12T01:40:50Z</wsu:Expires></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><GetPartitionAttachmentResponse xmlns="http://tempuri.org/"><GetPartitionAttachmentResult>1000</GetPartitionAttachmentResult></GetPartitionAttachmentResponse></soap:Body></soap:Envelope>
?Fileimage/jpg????JFIF??C
%# , #&')*)-0-(0%()(??C
(((((((((((((((((((((((((((((((((((((((((((((((((((????"??
???}!1AQa"q2???#B??R??$3br?
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz???????????????????????????????????????????????????????????????????????????
???w!1AQaq"2?B???? #3R?br?
$4?%?&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz????????????????????????????????????????????????????????????????????????????m5&?M?[? 8??p??j
I?C??????-???????\??s????Gmc?EP*?t??br,?????y?????(A?sX????"?7?S?2~????^????M??L???0????????????????P*???-k?J???]?C??|#y&?E?N?????uz~?ea????<?????V?4?????w?#????????L????Sl#??N4{Sr???v??????????s?oDt?J;??
?"???.v??"S$?}B.X?U???:(?^mj???h?a?V?F9?!.??v?kf?-??%??h?????"????A?C???#?? lr?6?u??M?W??e?X{???*+LxRX???
--.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
WSE_web.WSE2.WSE.GetPartitionAttachment(String sFileName, Int32 offset, Int32 size) in e:\dkdsoft\wes_test\wse_web\web references\wse2\reference.cs:73
WSE_web.WebForm1.Button1_Click(Object sender, EventArgs e) in e:\dkdsoft\wes_test\wse_web\webform1.aspx.cs:51
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1277
AI魔法探索家|陈工聊AI
2006-04-12
打赏
举报
回复
你试着返回一个值看
WS端应该是没问题的
这是我写的一个下载附件的
能用
/**//// <summary>
2 /// 分块下载附件
3 /// </summary>
4 /// <param name="sFileName">文件名</param>
5 /// <param name="offset">文件起始偏移量</param>
6 /// <param name="size">一次读取大小</param>
7 /// <returns>返回附件文件大小</returns>
8 [WebMethod]
9 public int GetPartitionAttachment( string sFileName,int offset, int size)
10 {
11 string[] names = sFileName.Split("\\".ToCharArray());
12 string filename=Server.MapPath(names[names.Length - 1]);
13
14 byte[] buffer = new byte[size];
15 FileStream fs = new FileStream(filename, FileMode.Open,FileAccess.Read,FileShare.Read);
16 fs.Seek(offset,SeekOrigin.Begin);
17 int numBytes;
18 if((numBytes = fs.Read(buffer,0,size)) > 0)
19 {
20 try
21 {
22 MemoryStream ms = new MemoryStream(buffer,0,size);
23 ms.Seek(0,SeekOrigin.Begin);
24
25 ResponseSoapContext.Current.Attachments.Add(new dime.DimeAttachment("File","image/jpeg",dime.TypeFormat.MediaType,ms));
26 return numBytes;
27 }
28 finally
29 {
30 fs.Close();
31 }
32 }
33 else
34 {
35 return 0;
36 }
37
38 }
sonkey
2006-04-12
打赏
举报
回复
to net_lover:
请问在那里改呢?
ws里面的方法代码如下:
public void GetAttachment(string imageName)
{
SoapContext myContext = ResponseSoapContext.Current;
string filePath = Server.MapPath("images\\" + imageName + ".txt");
DimeAttachment dimeImage = new DimeAttachment(
"text/txt", TypeFormat.MediaType, filePath);
dimeImage.Id = "tmpPic1.jpg";
//将新的DimeAttachment对象添加到SoapContext对象中,
myContext.Attachments.Add(dimeImage);
}
AI魔法探索家|陈工聊AI
2006-04-12
打赏
举报
回复
你的调用方使用了WSE么?
sonkey
2006-04-12
打赏
举报
回复
问题已经解决。
sonkey
2006-04-12
打赏
举报
回复
我项目里面没有
添加WSE引用 这一项啊!
只有
添加Web引用 这一项。
孟子E章
2006-04-11
打赏
举报
回复
类型不一致
将
application/dime改为text/xml
智能
客户端
(B/S+C/S)
它的主要用途是为有兴趣使用 .NET Framework 生成智能
客户端
应用程序和
XML
Web 服务的开发人员提供高质量的示例源代码。图 1 所示为 TaskVision 应用程序。 图 1 TaskVision 界面 TaskVision 解决方案...
C#调用Java jaxws开发的webservice服务
1、jaxws是基于wsdl国际标准基于
xml
传输协议,数据交互都基于标准
xml
格式,如果格式不正确交互会失败;关于jaxws整合spring并增加访问权限口令验证这里不再说明。 2、这里讲述开发注意事项、口令验证、数据加密(暂未...
SOAP协议解析
一、SOAP协议简介 1、SOAP简介 SOAP(Simple Object Accrss ... SOAP基于
XML
语言和XSD标准,其定义了一套编码规则,编码规则定义如何将数据表示为消息,以及怎样通过HTTP协议来传输SOAP消息,由四部分组成: ...
WebService理解和代码解析
/** WebServcie 概念 多个系统数据交换: 跨平台语言的相互通信; 如:java 的
客户端
和dotnet的服务器端的... 自描述:只需要知道请求
响应
的
类型
; 其他的不需要考虑 跨平台:不同语言可以相互通信。 通过网
2-3-Onvif协议:gSoap生成代码的使用方法
Envelope是SOAP消息中的根节点,是SOAP消息中必需的部分;中的第一个元素节点;Body是SOAP中必需部分,如果SOAP消息中没...所以,虽然看起来奇怪,但这种模式是一种常见的技巧,用于确保宏的可预测性和灵活性。
Web Services
12,166
社区成员
16,325
社区内容
发帖
与我相关
我的任务
Web Services
.NET技术 Web Services
复制链接
扫一扫
分享
社区描述
.NET技术 Web Services
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章