/Johan
On Tue, Mar 17, 2009 at 5:17 PM, Johan Nilsson <lists@markupartist.com> wrote:
> Hello,
>
> I have been trying to generate a java client to a soap service that is
> built with zf. The wsdl file is generated with Zend_Soap_AutoDiscover
> but I am not able to create the java client. Attached is the a dummy
> service and the code that creates the wsdl file. Im trying to create
> my java client using wsimport from jaxws.
> https://jax-ws.dev.java.net/jax-ws-ea3/docs/wsimport.html.
>
> Any other suggestions and or experiences on how to best create a java
> client for a zf soap service is welcome.
>
> This is the error I get.
>
> sh wsimport.sh http://localhost/soap/?wsdl
> [ERROR] Invalid wsdl:operation "method1": its a document-literal
> operation, message part must refer to a schema element declaration
> line 2 of http://localhost/soap/?wsdl
>
> I tried to patch the Zend_Soap_Wsdl to use literal according to this
> thread http://www.nabble.com/Problems-generating-WebService-client-from-WSDL-with-WSImport-td18614100.html
> but then of course I have to provide a schema for my operations. My
> patch is pretty stupid but available here if anyone interested,
> http://gist.github.com/80610
>
> When that patch applied I get the following error instead. Which seems
> to indicate that the wsdl file is correct if I am not mistaken.
>
> $ sh wsimport.sh http://localhost/soap/?wsdl
> [ERROR] Schema descriptor {http://localhost/soap/}method1Request in
> message part "inputParam" is not defined and could not be bound to
> Java. Perhaps the schema descriptor
> {http://localhost/soap/}method1Request is not defined in the schema
> imported/included in the WSDL. You can either add such
> imports/includes or run wsimport and provide the schema location using
> -b switch.
> line 2 of http://localhost/soap/?wsdl
>
> My test code, also available here if it is broken below.
> http://gist.github.com/80612
>
> <?php
> require_once "Zend/Loader.php";
> Zend_Loader::registerAutoload();
>
> class MyClass {
> /**
> * This method takes ...
> *
> * @param integer $inputParam
> * @return string
> */
> public function method1($inputParam) {
> return rand(1,10);
> }
> }
>
> if(isset($_GET['wsdl'])) {
> $autodiscover = new Zend_Soap_AutoDiscover();
> $autodiscover->setBindingStyle(
> array('style' => 'document',
> 'transport' => 'http://schemas.xmlsoap.org/soap/http')
> );
> $autodiscover->setOperationBodyStyle(
> array('use' => 'literal')
> );
>
> $autodiscover->setClass('MyClass');
> $autodiscover->handle();
> } else if (isset($_GET['client'])) {
> $client = new Zend_Soap_Client("http://localhost/soap/?wsdl");
> echo $client->method1(10);
> } else {
> $soap = new Zend_Soap_Server("http://localhost/soap/?wsdl");
> $soap->setClass('MyClass');
> $soap->handle();
> }
>
没有评论:
发表评论