Soap Web服务返回“内容类型application/soap + xml; charset = UTF-8" [英] Soap webservice returns "The content type application/soap+xml; charset=UTF-8"
本文介绍了Soap Web服务返回“内容类型application/soap + xml; charset = UTF-8"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试与某些SOAP Web服务(来自Joomla)进行通信 我不断收到此错误:
I'am trying to communicate with some SOAP webservice (which is from Joomla) I keep getting this error:
The content type application/soap+xml; charset=UTF-8 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 330 bytes of the response were: '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>401 Unauthorized</faultstring>
</SOAP-ENV:Fault>
</'.
我已经尝试过我能想到的所有绑定,但是我还没有弄清楚是什么导致了我的问题
I have tried every binding I can think of but I am yet to figure out what is causing my problems
代码:
using (NewPconradesenTest.Tag.siteredshopbtag100Client client = new Tag.siteredshopbtag100Client())
{
client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;
client.Open();
Console.WriteLine("\nClient State: " + client.State.ToString());
try
{
Tag.readList_filters filter = new Tag.readList_filters();
var result = client.readList(0, 99, emptyString, filter, emptyString, emptyString, language);
}
catch(Exception e)
{
Console.WriteLine(e.Message.ToString());
Console.WriteLine(e.InnerException.ToString());
Console.WriteLine(e.Source.ToString());
//Console.WriteLine(e.HResult.ToString());
//Console.WriteLine(e.StackTrace.ToString());
}
}
App.config:
App.config:
<bindings>
<customBinding>
<binding name="site.redshopb-tag.1.0.0">
<textMessageEncoding messageVersion="Soap11" />
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="XXXXXXXXXXXXXXXXXXXXXXX;view=tag&api=soap"
binding="customBinding" bindingConfiguration="site.redshopb-tag.1.0.0"
contract="Tag.siteredshopbtag100" name="site.redshopb-tag.1.0.0_Soap" />
</client>
我希望有人能帮助我,谢谢您的宝贵时间
I hope somebody can help me, Thanks for your time
推荐答案
我最终将代码发送给网络服务人员,最终救了我.
I ended up sending my code to the webservice guys, and the ended up saving me.
using (webservice.client request = new webservice.client ())
{
using (OperationContextScope scope = new OperationContextScope(request.InnerChannel))
{
OperationContext.Current.OutgoingMessageHeaders.Add(header);
HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Headers.Add("Authorization", "Basic " + this.Base64Encode(Program.username + ":" + Program.password));
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
var result = request.readList(0, 100, null, filter, null, null, Program.language);
this.printOutArrays(result);
}
}
这篇关于Soap Web服务返回“内容类型application/soap + xml; charset = UTF-8"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文