Autor Beitrag
GunHawK
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Mi 16.11.11 12:24 
Guten Morgen und Hallo an Alle!

Um den Zugriff per Soap und C++ auf einen Webservice zu testen habe ich als kleines Testprogramm einen WCF Server geschrieben, der eine Datumsabfrage zu Verfügung stellt. Auf diesen greife ich mit einem C++ Client via gSoap zu und frage das aktuelle Datum ab.
Die Übermittlung mit http Binding funktioniert einwandfrei!

Jetzt ist es für ein Projekt zwingend(!) notwendig, dass dieser Zugriff mit https durchgeführt wird!
Ich habe mich schon in das Thema eingelesen, allerdings bekomme ich das nicht zum laufen.

Meine App.config für http Binding sieht folgendermaßen aus:

ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <system.serviceModel>
    <bindings />
    <behaviors>
      <serviceBehaviors>
        <behavior name="MetaInformations">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8500/MetaInfo"
            httpsGetEnabled="false" httpsGetUrl="https://localhost:8500/MetaInfo"
            httpsGetBinding="" policyVersion="Default" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="MetaInformations" name="Host.Service">
        <endpoint address="http://localhost:8001/Service" binding="basicHttpBinding"
          bindingConfiguration="" name="MyEndPoint" bindingName="" contract="IHostFunctions" />
      </service>
    </services>
  </system.serviceModel>
</configuration>


Die config für mexHttpsBinding:
ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <system.serviceModel>
    <bindings />
    <behaviors>
      <serviceBehaviors>
        <behavior name="MetaInformations">
          <serviceMetadata httpGetEnabled="false" httpGetUrl="http://localhost:8500/MetaInfo"
            httpsGetEnabled="true" httpsGetUrl="https://localhost:8500/MetaInfo"
            httpsGetBinding="" policyVersion="Default" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="MetaInformations" name="Host.Service">
        <endpoint address="https://localhost:8100/Service" binding="mexHttpsBinding"
          bindingConfiguration="" name="MyEndPoint" bindingName="" contract="IHostFunctions" />
      </service>
    </services>
  </system.serviceModel>
</configuration>


Für https habe ich in der config die mexHttpsBinding eingestellt, allerdings habe ich das Probelm, dass ich im Programmaufruf nicht das Passende Binding finde:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
static void Main(string[] args)
{
 Uri baseAddress = new Uri("https://localhost:8500/MetaInfo");
 ServiceHost s_host = new ServiceHost(typeof(Hostfunctions),baseAddress);
 s_host.AddServiceEndpoint(typeof(HostInterface),/* was muss hier rein für Mex - https??????*/ new BasicHttpBinding(), "Datumsabfrage");
...


Funktioniert das mit gSoap überhaupt?
Ich habe versucht, mit wshttpBinding das zu machen, allerdings gibt's da den Fehler, dass gsoap mit gSoap1.1 und gSoap 1.2 durcheinander kommt und bei der Abfrage der Daten das Charset anmeckert.

Könnt ihr mir helfen, wie ich das mit https und gSoap zum Laufen bekomme?

Mfg
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Mi 16.11.11 15:07 
Ich gehe mal davon aus der Client basiert auf C#:
msdn.microsoft.com/e...ibrary/ms789011.aspx
GunHawK Threadstarter
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Do 17.11.11 14:11 
Danke für deine Antwort. Wie oben erwähnt ist der Client allerdings in C++.

Ich konnte das Problem lösen, indem ich normales basicHttpBinding verwende und dann den SecurityMode auf Transport setze. Nun muss ich noch SSL im Soap aktivieren.

Ohne TransportSecurity trat dann noch der Fehler auf, dass unterschiedliche Soap Versionen auf Server(1.1) und Client(1.2) verwendet wurden.
Dies konnte ich zum Glück mit folgender Lösung beheben:

Zitat:

For removing soap 1.2 namespace from the your web-service client project you should to change strings

{"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://www.w3.org/2003/05/soap-envelope", NULL},
{"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://www.w3.org/2003/05/soap-encoding", NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},to

{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", NULL, NULL},
{"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", NULL, NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", NULL, NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", NULL, NULL},in your .nsmap file and *Proxy.h file.


www.codeproject.com/...or2.aspx?msg=3960193