Search code examples
web-servicesvisual-studiowsdl

Unable to import WSDL in to Visual Studio 2012


Trying to integrate with a PHP SOAP-based web service. The client has given me a URL to a WSDL file which seems to confirm to the W3C Standard for WSDL.

I'm using the Add Web Reference option in the Advanced Dialog to add the reference. When I add the URL, the web browser in the dialog box displays the two methods in the WSDL specification, but there is an error message in the status area on the right, and the Add Reference button is disabled.

enter image description here

Error message:

The document at the url http://www.NAMEHERE.com/NAME/xml/test.php?wsdl was not 
recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The root element of a W3C XML Schema should be <schema> and its nam

If I run the WSDL through an online WSDL validator, it seems right and, like I say, it does appear to conform to standards.

In addition, I've tried using the the WSDL.EXE command-line and tried SOAP, SOAP12, HTTPGET and HTTPPOST protocols, each time getting the same error message.

WSDL Excerpt here:

<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:tns="http://www.NAMEHERE.com/NAME/xml/namespace" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns="http://schemas.xmlsoap.org/wsdl/" 
targetNamespace="http://www.NAMEHERE.com/NAME/xml/namespace">
<types>
<xsd:schema targetNamespace="http://www.NAMEHERE.com/NAME/xml/namespace">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:complexType name="AddressWO">

....

The cilent says that they haven't experienced this issue with any other partners, who are all able to integrate successfully. Albeit, they are PHP to PHP.

I've searched SO and am unable to find the same issue explicity (or any suitable answer).

Any ideas?


Solution

  • After spending a fair amount of time on this, it turns out that the WSDL wasn't perfect afterall. Our business partner needed to make a couple of minor corrections to the WSDL before Visual Studio could import it.

    The issue was that they had a minOccurs attribute on an element, which was invalid in that scenario.

    The thing to note here is that several online validators said the WSDL was valid, as do the PHP clients we tried.

    Then, we used the WLIMPORT program within JDK 1.6+ and this gave a very detailed list of errors in the WSDL, pointing to the exact cause of the issue.

    So, our business partner corrected the specification at their end and now Visual Studio imports the WSDL successfully.

    Hope this helps.