Hi guys,
I created a small soap service with Zend_Soap_Server and Zend_Soap_AutoDiscover
but I cannot consume its data via a java soap client. I tried it all the day but
it won´t work.
----- SNIP -----
class MyFooService
{
/**
* @return string
*/
public function getStaticString() {
return 'Hello World';
}
}
----- SNAP -----
It is accessable (for me!) via http://jason/Laboratory/JMS/service.php which is
the service and http://jason/Laboratory/JMS/service.php?wsdl which will show
wsdl definition. The created wsdl definition looks like this:
----- SNIP -----
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://jason/Laboratory/JMS/service.php"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
name="MyFooService"
targetNamespace="http://jason/Laboratory/JMS/service.php">
<portType name="MyFooServicePort">
<operation name="getStaticString">
<input message="tns:getStaticStringRequest" />
<output message="tns:getStaticStringResponse" />
</operation>
</portType>
<binding name="MyFooServiceBinding" type="tns:MyFooServicePort">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="getStaticString">
<soap:operation
soapAction="http://jason/Laboratory/JMS/service.php#getStaticString" />
<input>
<soap:body use="literal"
namespace="http://jason/Laboratory/JMS/service.php" />
</input>
<output>
<soap:body use="literal"
namespace="http://jason/Laboratory/JMS/service.php" />
</output>
</operation>
</binding>
<service name="MyFooServiceService">
<port name="MyFooServicePort" binding="tns:MyFooServiceBinding">
<soap:address location="http://jason/Laboratory/JMS/service.php" />
</port>
</service>
<message name="getStaticStringRequest" />
<message name="getStaticStringResponse">
<part name="getStaticStringReturn" type="xsd:string" />
</message>
</definitions>
----- SNAP -----
As you can see I do not use Zend_Soap_AutoDiscover in its original version (see
attached MyAutoDiscover.diff, could not extend and use my own class because I
need access to private class properties). I needed to change <soap:body
use="encoded" encodingStyle="..." /> to <soap:body use="literal" namespace="..."
/> because wsimport (small tool included in jdk) cannot handle "encoded". So I
used following command to create java classes from wsdl definiton:
# wsimport -keep http://jason/Laboratory/JMS/service.php?wsdl
So I got this two java classes:
# jason.laboratory.jms.service.MyFooServicePort.java
# jason.laboratory.jms.service.MyFooServiceService.java
After that I created a soap client using these classes (jdk1.6.0_10):
----- SNIP -----
package jason.laboratory.jms.myfooclient;
import jason.laboratory.jms.service.*;
public class MyFooClient
{
/**
* @param args
*/
public static void main(String[] args)
{
MyFooServiceService mfss = new MyFooServiceService();
MyFooServicePort mfsp = mfss.getMyFooServicePort();
String result = mfsp.getStaticString();
if (result != null) {
System.out.println("Result: " + result);
} else {
System.out.println("Result is NULL");
}
}
}
----- SNAP -----
I expected "Result: Hello World" but I always get "Result is NULL".
Zend_Soap_Client has no problems consuming the service.
It looks like an java problem, but we also tested the same soap server using a
Microsoft Dynamics AX soap client and got the same result. Okay we do not get
"NULL" as return value from service, the Microsoft soap client shows "1" as
result.
So I am searching for a solution how to get it working. I am absolutly clueless
why I do not get the correct result. Is there someone who can verify or solve my
problem? :-)
If there are any questions or if there are more information needed, please ask!
If needed I can upload my sources.
-- Jan
Index: AutoDiscover.php
===================================================================
--- AutoDiscover.php (revision 12830)
+++ AutoDiscover.php (working copy)
@@ -244,7 +244,7 @@
}
/* <wsdl:binding>'s */
- $operation = $wsdl->addBindingOperation($binding,
$method->getName(), array('use' => 'encoded', 'encodingStyle' =>
"http://schemas.xmlsoap.org/soap/encoding/"), array('use' => 'encoded',
'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"));
+ $operation = $wsdl->addBindingOperation($binding,
$method->getName(), array('use' => 'literal', 'namespace' => $this->_uri),
array('use' => 'literal', 'namespace' => $this->_uri));
$wsdl->addSoapOperation($operation, $uri->getUri() . '#'
.$method->getName());
/* </wsdl:binding>'s */
}