简体   繁体   中英

Importing a PHP generated WSDL into Visual Studio 2017

I'm currently trying to interface with a web service via SOAP (unfortunately the only interface/protocol they offer). To make it easier to consume their web service they offer a WSDL which can be viewed here: http://demo.coveto.de/soap?wsdl (It's tagged as content type text/html instead of application/soap+xml, which makes it look really weird and VS won't accept it, so it has to be saved to a local file).

I'm having problems importaing said WSDL into Visual Studio 2017. The recommended way, as far as I understand, is to add the WSDL (URL or local file) as a service reference, which I did. This pops up the following errors in VS17 which are unclear to me:

Warning     Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:portType[@name='coveto_soapWebservicePort']
XPath to Error Source: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:binding[@name='coveto_soapWebserviceBinding']    

Warning     Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:binding[@name='coveto_soapWebserviceBinding']
XPath to Error Source: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:service[@name='coveto_soapWebserviceService']/wsdl:port[@name='coveto_soapWebservicePort']

Warning     Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: The datatype 'http://schemas.xmlsoap.org/soap/encoding/:Array' is missing.
XPath to Error Source: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:portType[@name='coveto_soapWebservicePort']  

(Note that while it says warning, not error, there is an actual error which says nothing more but to check other warnings)

I would assume only the last one is actually a problem, the other two are simply caused by it.

I don't know much about SOAP or WSDL, so I'm having trouble pinpointing what exactly the problem is. I've tried downloading the schema mentioned in the warnings, but after replacing the URL either in various places or in all places with the filename (same directory as the wsdl file) I get a lot of new errors such as: type X is already defined or couldn't find schema with target namespace . I attribute this to my general non-understanding of the structure of a WSDL file.

Help is much appreciated.

I've tried to import the WSDL file into Visual Studio 2017.

  1. The link to the WSDL file http://demo.coveto.de/soap?wsdl is not valid, because to response is Content-Type:text/html; charset=UTF-8 Content-Type:text/html; charset=UTF-8 . The content type must be Content-Type:text/xml;charset=UTF-8 .

  2. The PHP internal SoapClient is not very good. Try to use the Zend SoapClient instead.

This works for me:

<?php

// composer require zendframework/zend-soap

require_once __DIR__ . '/vendor/autoload.php';

$client = new Zend\Soap\Client("http://demo.coveto.de/soap?wsdl");
$result1 = $client->getFunctions();
var_dump($result1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM