7

I am converting a Delphi 2007 program to Delphi XE2 and having a problem with the following error message:

Unable to retrieve the URL endpoint for service/port "/" from WSDL 'http://.....'

The service I am connecting to is written in Delphi 2007.

On 2007 it compiles and runs without problems. On XE2 with the same code it falls over with the error.

I have tried re-importing the interface using the new WSDL importer with defaults set but no joy.

I have also tried setting the port and service names and the error persists. Not sure what info is of use but as far as I can tell it is connecting.

This is the operation of the method that I am using

<operation name="CheckRegistration">
  <soap:operation soapAction="urn:ScubaUpdateWSIntf-IScubaUpdateWS#CheckRegistration" style="rpc"/>
  <input>
    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"     namespace="urn:ScubaUpdateWSIntf-IScubaUpdateWS"/>
  </input>
  <output>
    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:ScubaUpdateWSIntf-IScubaUpdateWS"/>
  </output>
</operation> 

This is the message:

<message name="CheckRegistration10Request">
  <part name="centreId" type="xs:int"/>
  <part name="centreName" type="xs:string"/>
  <part name="checkActiveOnly" type="xs:boolean"/>
</message>
<message name="CheckRegistration10Response">
  <part name="return" type="xs:boolean"/>
</message>

Apart from importing the WSDL, throwing on an HTTPRIO and calling the method with

(HTTPRIO1 as IScubaUpdateWS).CheckRegistration(strtoint(tcentre),tcentreName,true);

I don't think I am doing anything else and as I say the same code works on Delphi 2007.

SSE
  • 445
  • 2
  • 10
  • 29
Richard Turner
  • 423
  • 4
  • 12
  • 2
    At design-time, when you set the HTTPRIO.WSDLLocation property, are you then able to select the HTTPRIO.Service and HTTPRIO.Port properties? You should be able to set Service and Port at design-time, if not, then there may be something wrong with the URL. I've had this issue many times, and it seems as soon as I set it once properly at design-time, then the error goes away.. – John Easley Jan 23 '12 at 18:27
  • Hi John, Thanks, the port is blank in the Delphi 2007 ide as well as in Xe2. Setting it just changes the error message. I have just tried to connect to another delphi WSDL and have the same problem. I am going to try to connect to a c# WSDL or one of the Amazon DLLs to see if I can determine whether its just delphi wsdls that are causing the issue. I will post back later today. – Richard Turner Jan 24 '12 at 07:51
  • Just confirmed that Xe2 can connect to a .net web service. There must be something in my delphi web services that is causing the endpoint error. – Richard Turner Jan 24 '12 at 08:17
  • 2
    John - Seems that I can solve it for one of my services there are TWO ports and services with the SAME - I selected the second one and it worked. Question is WHY? two on DELPHI XE2. I also cant work out which combination to use on the other web service (sods law being the one i need)! – Richard Turner Jan 24 '12 at 08:29
  • There are multiple Services with the same name? I think therein lies the problem.. you may want to evaluate the construction of your web service.. – John Easley Jan 24 '12 at 17:02
  • @JohnEasley yes thats right but only when using DELPHI XE2 as an example this one http://www.webservicex.net/CurrencyConvertor.asmx?WSDL is showing 2 services called currencyconverter in XE2. You were right with your initial answer what I was missing was that I set the WSDL in code which is fine for Delphi 2007 because it only finds one service and sets accordingly - for XE2 it all went awol. – Richard Turner Jan 25 '12 at 20:09

2 Answers2

2

Solved. Well sort of! Seems like Delphi XE2 is finding 2 services where as Delphi 2007 is finding one. The program I am using is reading the WSDL location from the registry and setting it. On Delphi 2007 it is fine because it is taking the one and only service and making that selected port/service. On Delphi XE2 it is resetting the WSDL location has results in the port and service being cleared. Thanks to @JohnEasley for pointing me in the right direction. To solve I am now having to use the following code after changing the WSDL location. Not sure it will work for every one as I am assuming the first entry is the one that is required

servicenames:=Tdomstrings.Create;
portnames:=Tdomstrings.Create;
HTTPRIO1.WSDLItems.GetServices(servicenames);
if servicenames.count>0 then 
begin
 HTTPRIO1.Service:=servicenames[0];
 HTTPRIO1.WSDLItems.GetPortsForService(servicenames[0],portnames);
 if portnames.count>0 then
  HTTPRIO1.Port:=portnames[0];
end;
servicenames.clear;
servicenames.Free;
portnames.clear;
portnames.Free;

Thanks guys

Richard Turner
  • 423
  • 4
  • 12
0

in delphi 10.3 you must set "HTTPRIO1"'s property "Port" and "WSDLLocation" explicitly at runtime.

for sample in form "create" event:

HTTPRIO1.WSDLLocation:=defWSDL; 
//HTTPRIO1.URL:=defURL;    
//one of URL or WSDLLocation is enough.    
HTTPRIO1.Service:=defSvc;     
HTTPRIO1.Port:=defPrt;     

Thanks