Zend Framework 2 SOAP is not compatible with .NET.

I am trying to create a SOAP server in my ZF2 application, which I can import using Visual Studio with a wizard into a C # application. I already created a service and tested it using soapUI. I ran the WS-I conformance test in soapUI and my service passed it. However, when I try to add a service to a C # application using Visual C # Express 2008, it says that there is no web service discovery information in the HTML document.

Here is the code I use in my ZF2 controller:

public function exampleAction() { if (isset($_GET['wsdl'])) { $soapAutoDiscover = new AutoDiscover(); $soapAutoDiscover->setBindingStyle(array('style' => 'document')); $soapAutoDiscover->setOperationBodyStyle(array('use' => 'literal')); $soapAutoDiscover->setClass('SoapClass'); $soapAutoDiscover->setUri($serverUrl); echo $soapAutoDiscover->generate()->toXml(); } else { $soap = new Server($serverUrl . '?wsdl'); $soap->setClass('SoapClass'); $soap->handle(); } } 

This is the SoapClass class:

 class SoapClass{ /** * returns the sum of two parameters * @param int $a * @param int $b * @return int */ public function sum ($a, $b){ return $a + $b; } /** * twice function doc * @param int $a * @return int */ public function twice($a){ return $a * 2; } } 

Any ideas?

+4
source share
3 answers

After reading and re-reading again, several messages and documentation that I found on this finally came across a solution:

SoapClass is fine, but at the time of generating wsdl and the server, I had to make some changes:

 public function exampleAction() { if (isset($_GET['wsdl'])) { //this is new: $soapAutoDiscover = new AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence()); $soapAutoDiscover->setBindingStyle(array('style' => 'document')); $soapAutoDiscover->setOperationBodyStyle(array('use' => 'literal')); $soapAutoDiscover->setClass('SoapClass'); $soapAutoDiscover->setUri($serverUrl); //so this is: header("Content-Type: text/xml"); echo $soapAutoDiscover->generate()->toXml(); } else { $soap = new Server($serverUrl . '?wsdl'); //drop this: //$soap->setClass('SoapClass'); //and instead, add this: $soap->setObject(new DocumentLiteralWrapper(new SoapClass())); $soap->handle(); } } 
+4
source

I think you need to specify the transport:

 $style = array('style'=>'document', 'transport'=>'http://schemas.xmlsoap.org/soap/http'); $soapAutoDiscover->setBindingStyle($style); 

And the title should be:

 header('Content-type: application/soap+xml'); 
+2
source

Here you can read about several compatibility issues with the ZF SOAP component:

http://framework.zend.com/issues/browse/ZF-6349

0
source

All Articles