0

I have this WSDL:

<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:tns="http://sei.esempio.it/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:ns2="http://schemas.xmlsoap.org/soap/http" 
    xmlns:ns1="http://esempio.it/" name="XServiziService" 
    targetNamespace="http://sei.esempio.it/">
<wsdl:import location="http://example.lan:8082/XServizi?wsdl=Sei.wsdl" 
             namespace="http://esempio.it/"> </wsdl:import>
<wsdl:binding name="XServiziServiceSoapBinding" type="ns1:Sei">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="HelloWorldOperation">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="HelloWorldOperation">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="HelloWorldOperationResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="XServiziService">
  <wsdl:port binding="tns:XServiziServiceSoapBinding" name="XServiziPort">
    <soap:address location="http://example.lan:8082/XServizi"/>
  </wsdl:port>
</wsdl:service>
</wsdl:definitions>

I tried to import with SoapClient in PHP, but I get this error:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://example.lan:8083/XServices?wsdl' : failed to load external entity "https://example.lan:8083/XServices?wsdl"

I added also login and pass in SoapClient. I don't know why, with other WSDL, it works.

I can't import with SoapUI either. I get this error:

Error loading [http://example.lan:8082/XServices?wsdl=Sei.wsdl]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: does not close tag .

I disabled also the proxy in SoapUI, but it doesn't work.

Any suggestions?

Bogdan
  • 23,890
  • 3
  • 69
  • 61
Marco Bozzola
  • 179
  • 1
  • 3
  • 17
  • My assumption is because your WSDL imports another file for it's types and PHP client can't resolve it. See this for an explanation: https://stackoverflow.com/questions/67019333/apach-cxf-soap-wsdl-without-complextype/. Is this a service you control? If yes, then you can obtain one WSDL by using the same XML namespace on all your service components. – Bogdan Apr 21 '21 at 13:13
  • no i don't have control over this WSDL mmm ah u mean this part =Sei.wsdl"? – Marco Bozzola Apr 21 '21 at 13:19
  • if i dont have control over it, how can import in a client? :S – Marco Bozzola Apr 21 '21 at 13:25
  • Looking at the WSDL it seems it's the WSDL for a toy web service. My question is, did you build this web service? Not the WSDL, the web service! – Bogdan Apr 21 '21 at 13:50
  • no i dont build the webservice. it is not a toy webservice i manually erased other 2 real services in wsdl for privacy, and i leave only that helloworld. In this case i had to tell them to modify in unique namespace or how can i import with php? thx – Marco Bozzola Apr 21 '21 at 21:23

1 Answers1

0

Based on the error messages, the problem is related to the <wsdl:import> inside the WSDL file you posted. Your WSDL is composed of two parts: the one you are diplaying and the one that can be found at the URL http://example.lan:8082/XServizi?wsdl=Sei.wsdl

Your error messages show two different things.

One has a problem with https://example.lan:8083/XServices?wsdl and the other with http://example.lan:8082/XServices?wsdl=Sei.wsdl. I'm not sure how you edited these URLs for privacy when posting this question and why one is on port 8083 and the other on port 8082, but the idea is that all parts of the WSDL need to be accessible:

  • the URL of the main WSDL needs to be accessible by your tooling;
  • the URL that the main WSDL imports also needs to be accessible by your tooling;

Only then will your tooling be able to read the WSDL and all its parts and generate a SOAP client.

Note also that some tools choke on WSDLs with imports (see here for details). Not familiar enough with PHP SoapClient though to know if that's the case here.

Since you can't control the service, your options are to somehow make both XMLs available to your tooling.

First make sure the URLs are accessible.

If that's not the case, then somehow get a hold of their content. When you have them, you could save the content of the two URLs in your local PHP server as main.wsdl (this is the WSDL you are showing in your question) and second.xml (this is what's imported). Then in your main.wsdl you change the import location. For example, if you expose the files locally as http://localhost:80/main.wsdl and http://localhost:80/second.xml then in main.wsdl you change the import to look like this:

<wsdl:import location="http://localhost:80/second.xml" namespace="http://esempio.it/"></wsdl:import>

then point the SoapClient or SoapUI to read http://localhost:80/main.wsdl instead.

You could try this on disk and place the files one next to each other in the same folder, then change the import to:

<wsdl:import location="second.xml" namespace="http://esempio.it/"></wsdl:import>

then point the tools to the main.wsdl file on disk. I'm not sure this will work though. Have never tried it. SoapUI might be able to fetch the files from the same folder, the PHP SoapClient I doubt so.

There is also the option of downloading both XML files and combine them into just one WSDL file (basically resolving the import manually) then use just this file for your tooling. You will have to know what you are doing though, in order to obtain a valid and correct WSDL file.

Or finally, you could ask the service provider to give you just one WSDL file you can use instead. There is no point of asking them to change the current WSDL because most likely they have other clients too and fixing this for you might break stuff for somebody else (as mentioned in the link above).

But this is probably just an accessibility issue, so make sure those URLs are accessible from your browser before using them with SOAP tools.

Bogdan
  • 23,890
  • 3
  • 69
  • 61