Question

Je suis en train d'écrire une simple application preuve de concept client WCF serveur + gSOAP en utilisant le protocole SOAP 1.2. Voici le code du serveur:

[ServiceContract(Namespace="http://test.com")]
public interface IService1
{
    [OperationContract]
    void HelloWorld();
}

[ServiceBehavior(Namespace = "http://test.com")]
public class Service1 : IService1
{
    public void HelloWorld()
    {
    }
}

static void Main(string[] args)
{
    var svc =  new Service1();
    Uri uri = new Uri("http://localhost:8201/Service1");
    ServiceHost host = new ServiceHost(typeof(Service1), uri);
    host.Description.Namespace = "http://test.com";

    var binding = new WSHttpBinding() { Namespace = "http://test.com" };
    ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IService1), binding, uri);
    endpoint.Behaviors.Add(new InlineXsdInWsdlBehavior());

    host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpGetEnabled = true });
    var mex = host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
    host.Open();

    Console.ReadLine();
}

Alors je lance un service et générer du code en utilisant les commandes suivantes:

wsdl2h.exe -gyf -t WS/WS-typemap.dat -o Service.h http://localhost:8201/Service1?wsdl WS/WS-Addressing05.xsd
soapcpp2.exe -C -L -w -x -i -2 Service.h -ID:\...\gsoap-2.7\gsoap\import

Je Compile suivant le code C ++:

#include "soapWSHttpBinding_USCOREIService1Proxy.h"
#include "WSHttpBinding_USCOREIService1.nsmap"
#include "stdsoap2.h" 

int _tmain(int argc, _TCHAR* argv[])
{
    WSHttpBinding_USCOREIService1Proxy svc;

    _ns1__HelloWorld req;
    _ns1__HelloWorldResponse rsp;
    int hr = svc.HelloWorld( &req, &rsp );
    if ( hr != SOAP_OK )
    {
        _tprintf( _T("Error: %i\n"), hr );
    }

    return 0;
}

et cette erreur génère 8 (SOAP_MUSTUNDERSTAND). Avez-on jamais produit de travail à WCF gSOAP lien du tout? Qu'est-ce que je fais mal?

Était-ce utile?

La solution

Je suppose -a commutateur soapcpp2 erreur dans 8 fixe, de sorte que les commutateurs sont maintenant:

soapcpp2.exe -C -L -w -x -i -2 -a Service.h -I<...path...>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top