Skip to Content
0
Nov 16, 2012 at 01:22 PM

Consuming B1WS web services from C++

116 Views

I have B1 8.82 at 192.168.81.122. DI Server is running. I installed B1WS 1.1.

In a Python test client I saw a first odd behaviour is this: leaving "http://localhost/B1WS/Service.asmx" as soap:address location in LoginService.wsdl it works, while changing it to "http://192.168.81.122/B1WS/Service.asmx" it gives me "HTTPError: HTTP Error 500: Internal Server Error".

So we assume we have to use localhost in the WSDL.

The problem is I'm not able to cosume LoginService with C++.

This is my WS client code:

  // create client  _di_LoginServiceSoap  ls = GetLoginServiceSoap(True, "http://192.168.81.122/B1WS/WebReferences/LoginService.wsdl");  Login * loginParams = new Login();  loginParams->DatabaseServer  = "192.168.81.122";  loginParams->DatabaseName    = "SBODemoIT";  loginParams->DatabaseType    = DatabaseType::dst_MSSQL2008;  loginParams->DatabaseUsername= "sa";  loginParams->DatabasePassword= "xxxxxxxxx";  loginParams->CompanyUsername = "manager";  loginParams->CompanyPassword = "manager";  loginParams->Language        = Language::ln_English;  loginParams->LicenseServer   = "192.168.81.122:30000";  // invoke Login web method  LoginResponse * loginResp = ls->Login( loginParams );  UnicodeString sessionID = loginResp->SessionID;  ShowMessage(sessionID);

Where GetLoginServiceSoap is following method, belonging to LoginService.cpp, generated by RAD Studio XE2 with "Import WSDL...":

_di_LoginServiceSoap GetLoginServiceSoap(bool useWSDL, System::String addr, Soaphttpclient::THTTPRIO* HTTPRIO){  static const char* defWSDL= "http://192.168.81.122/B1WS/WebReferences/LoginService.wsdl";  static const char* defURL = "http://localhost/B1WS/Service.asmx";  static const char* defSvc = "LoginService";  static const char* defPrt = "LoginServiceSoap12";  if (addr=="")    addr = useWSDL ? defWSDL : defURL;  Soaphttpclient::THTTPRIO* rio = HTTPRIO ? HTTPRIO : new Soaphttpclient::THTTPRIO(0);  if (useWSDL) {    rio->WSDLLocation = addr;    rio->Service = defSvc;    rio->Port = defPrt;  } else {    rio->URL = addr;  }  _di_LoginServiceSoap service;  rio->QueryInterface(service);  if (!service && !HTTPRIO)    delete rio;  return service;}

I tested it with following configurations:

  • Configuration 1 (the one that worked for Python client): With soap:address location="http://localhost/B1WS/Service.asmx" in the WSDL and defPrt = "LoginServiceSoap" in the client I get:
ESOAPHTTPException with message 'Unable to retrieve the URL endpoint for Service/Port 'LoginService'/'LoginServiceSoap' from WSDL 'http://192.168.81.122/B1WS/WebReferences/LoginService.wsdl'.

  • Configuration 2: With soap:address location="http://localhost/B1WS/Service.asmx" in the WSDL and defPrt = "LoginServiceSoap12" in the client I get:
ESOAPHTTPException with message 'Impossibile trovare l'intestazione richiesta - URL:http://localhost/B1WS/Service.asmx - SOAPAction:LoginService/Login.

(it could be translated to "The requested header was not found")

  • Configuration 3: With soap:address location="http://192.168.81.122/B1WS/Service.asmx" in the WSDL and defPrt = "LoginServiceSoap" in the client I get:
ESOAPHTTPException with message 'Impossibile trovare l'intestazione richiesta - URL:http://localhost/B1WS/Service.asmx - SOAPAction:LoginService/Login.

  • Configuration 4: With soap:address location="http://192.168.81.122/B1WS/Service.asmx" in the WSDL and defPrt = "LoginServiceSoap12" in the client I get:
EDOMParseError with message 'È previsto un valore letterale stringa, ma non sono state trovate virgolette aperte.Line: 20    <span><H1>Errore server nell.

(it could be translated to "A string literal was expected, but no opening quote character was found." and then "Server error in.". I guess EDOMParseError is due to the apostrophie which probably follows "nell". Anyway what we are interested to is that probably we had an Italian HTML response reporting a server error.)

So which would be the correct configuration and how could I make my WS client work? Thanks!