Meilleur auteur de réponses
Consommer un webservice (avec SOAP 1.2)

Question
-
Hello everybody,
Je cherche à appeler un webservice dont le SOAP est 1.2
Avec le SOAP 1.1, ça a marché sans problème:
public async void Search() { //Create a simple request var body = new helloWorldRequestBody("B10016"); var request = new helloWorldRequest(); request.Body = body; //Create a client var client = new HelloWorldClient(); var bodyResponse = new helloWorldResponseBody(); //Get the response var response = await client.helloWorldAsync(request); ... }
Puis, avec un autre webservice, cette fois-ci avec le SOAP 1.2, il n'y a pas de constructeur sans paramètre (il fallait y ajouter un binding et un endpoint):
public async void SearchNeed() { //Create a complex request with 3 elements var request = new getMarketedRequest(); var servicecontext_request = request.serviceContext; var marketcondition_request = request.marketConditions; var salecontext_request = request.saleContext; //Create a binding and an endpoint var bin = new BasicHttpBinding(); var binws = new NetHttpBinding(); Uri baseAddress = new Uri("http://item-b10016:8088/mockMarketedBinding"); var edp = new EndpointAddress(baseAddress); //Create a client var client = new MarketedClient(bin, edp); var response = await client.getMarketedAsync(servicecontext_request, marketcondition_request, salecontext_request); ... }
J'ai essayé deux types de binding (BasicHttpBinding et NetHttpBinding) dans getMarketedClient. Puis en utilisant getMarketedAsync, tous les deux ont mené à une erreur
Le 1er (BasicHttpBinding):
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).
Le 2ème (NetHttpBinding):
The content type text/html; charset=iso-8859-1 of the response message does not match the content type of the binding (application/soap+msbin1).
Cdt,
F2O
- Modifié F2O lundi 22 avril 2013 14:05
Réponses
-
Bonjour,
Finalement, je suis parvenue à trouver une solution. SOAP 1.2 est bien supporté en Windows Store Apps.
Il fallait trouver le "bon" binding.
La ligne:
var bin = new BasicHttpBinding();
Je l'ai remplacé par:
CustomBinding bin = new CustomBinding(); TextMessageEncodingBindingElement tebe = new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8); HttpTransportBindingElement htbe = new HttpTransportBindingElement();
bin.Elements.Add(tebe);
bin.Elements.Add(htbe);Cette fois, cela marche.
Cdt,
F2O
Toutes les réponses
-
Bonjour
A priori SOAP 1.2 n'est pas supporté en Windows Store Apps.
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/4ea64394-238c-4d99-8f42-1cbafb4f6cfe/
Cordialement,
-
Bonjour,
Finalement, je suis parvenue à trouver une solution. SOAP 1.2 est bien supporté en Windows Store Apps.
Il fallait trouver le "bon" binding.
La ligne:
var bin = new BasicHttpBinding();
Je l'ai remplacé par:
CustomBinding bin = new CustomBinding(); TextMessageEncodingBindingElement tebe = new TextMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8); HttpTransportBindingElement htbe = new HttpTransportBindingElement();
bin.Elements.Add(tebe);
bin.Elements.Add(htbe);Cette fois, cela marche.
Cdt,
F2O