PDA

View Full Version : javax.xml.rpc.ServiceException: Cannot find service:


cig
Sep 22nd, 2004, 06:41 AM
Hi

I am trying to use JaxRpc to consume a web service. I have configured my bean the same way that the jpetstore sample shows, ie: as follows


<beans>
<bean id="HelloWorldService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean">
<property name="serviceFactoryClass"><value>org.apache.axis.client.ServiceFactory</value></property>
<property name="wsdlDocumentUrl"><value>http://maa5.rmb.co.za:8008/HelloWorldServiceMike250.wsdl</value></property>
<property name="namespaceUri"><value>http://maa5.rmb.co.za:8008/HelloWorldServiceMike250</value></property>
<property name="portName"><value>HelloWorldService</value></property>
<property name="serviceName"><value>urn:HelloWorldService</value></property>
<property name="serviceInterface"><value>jaxrpc.HelloWorldService</value></property>
</bean>
</beans>

I have tried changing the namespaceUri and serviceName to every possible configuration I can think of but I always get the following exception:


INFO: Creating shared instance of singleton bean 'HelloWorldService'
2004/09/22 12:29:33 org.springframework.beans.factory.support.Abstract BeanFactory destroySingletons
INFO: Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [HelloWorldService]; Root of BeanFactory hierarchy}
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'HelloWorldService' defined in file [C:\dev\workspace\spring\applicationContext.xml ]: Initialization of bean failed; nested exception is javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.xml.rpc.ServiceException: Cannot find service: {http://maa5.rmb.co.za:8008/HelloWorldServiceMike250}urn:HelloWorldService
javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.xml.rpc.ServiceException: Cannot find service: {http://maa5.rmb.co.za:8008/HelloWorldServiceMike250}urn:HelloWorldService
at org.apache.axis.client.Service.initService(Service .java:278)
at org.apache.axis.client.Service.<init>(Service.java:193)
at org.apache.axis.client.ServiceFactory.createServic e(ServiceFactory.java:232)
at org.springframework.remoting.jaxrpc.LocalJaxRpcSer viceFactory.createJaxRpcService(LocalJaxRpcService Factory.java:152)
at org.springframework.remoting.jaxrpc.JaxRpcPortClie ntInterceptor.afterPropertiesSet(JaxRpcPortClientI nterceptor.java:226)
at org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean.afterPropertiesSet(JaxRpcPortProxyFac toryBean.java:52)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:801)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:249)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:177)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:159)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:177)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:268)
at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationContext.java:60)
at jaxrpc.ServiceLauncher.bind(ServiceLauncher.java:2 7)
at jaxrpc.ServiceLauncher.main(ServiceLauncher.java:3 1)


When I use Axis with the wsdl2java ant task, with the same url it works fine, can anybody tell me what I should be entering for the following:
1. url
2. namespaceUri
3. portName
4. serviceName


Below is the wsdl file I am using:



<?xml version="1.0" encoding="utf-8" ?>
- <definitions targetNamespace="urn" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="HelloOperation" />
- <message name="HelloOperationResponse">
<part name="return" type="xsd:string" />
</message>
- <portType name="HelloWorldService">
- <operation name="HelloOperation">
<documentation parameterOrder="">Hello World Method</documentation>
<input message="tns:HelloOperation" />
<output message="tns:HelloOperationResponse" />
</operation>
</portType>
- <binding name="HelloWorldService" type="tns:HelloWorldService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http/" />
- <operation name="HelloOperation" selector="hello">
<soap:operation soapAction="" />
- <input>
<soap:body use="literal" namespace="urn" />
</input>
- <output>
<soap:body use="literal" namespace="urn" />
</output>
</operation>
</binding>
- <service name="HelloWorldService">
- <port name="HelloWorldService" binding="tns:HelloWorldService">
<soap:address location="http://maa5.rmb.co.za:8819/HelloWorldService" />
</port>
</service>
<schemaBindings />
</definitions>

Please help!!! Also read the relevant sections from Rod's book "J2EE Development Without EJB" but I'm still not winning

ram_2000
Sep 25th, 2004, 05:39 PM
cig,

Try the following:

<property name="serviceName"><value>HelloWorldService</value></property>

(no urn: in the service name)

<property name="namespaceUri"><value>urn</value></property>

Did you create the WSDL manually? ..or autogenerated by AXIS?

cig
Sep 27th, 2004, 04:27 AM
Hi ram_2000

Thanks for your reply, unfortunately that did not work. To answer your question of whether the wsdl is generated by AXIS, the answer is yes.

Do you have a simple example which includes the generated wsdl?
That way I can map the parameters.

thanks

lucas
Sep 28th, 2004, 04:12 AM
Hi all,
I've the same problem, with an identical configuration. The axis webservice is up and running and I'm able to contact it using an apache Call or the wsdl2java generated stubs, but there seem to be configuration errors I can't find out.
Tks in advance.

Lucas

ram_2000
Sep 29th, 2004, 03:05 AM
Here is a sample configuration i used. I used it against the "stock" sample in the AXIS samples folder. You can look at the GetQuote.wsdl and deploy.wsdd in the 'stock' samples folder.


<bean id="jaxrpc" class="org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean">
<property name="serviceInterface">
<value>jaxrpc.StockService</value>
</property>
<property name="portInterface">
<value>jaxrpc.RemoteStockService</value>
</property>
<!--
<property name="serviceFactoryClass">
<value>org.apache.axis.client.ServiceFactory</value>
</property>
-->
<property name="wsdlDocumentUrl">
<value>http://localhost:8080/axis/services/urn:xmltoday-delayed-quotes?wsdl</value>
</property>
<property name="namespaceUri">
<value>http://localhost:8080/axis/services/urn:xmltoday-delayed-quotes</value>
</property>
<property name="serviceName">
<value>StockQuoteServiceService</value>
</property>

<property name="portName">
<value>GetQuote</value>
</property>
<property name="username">
<value>user2</value>
</property>
<!--
<property name="endpointAddress">
<value>http://localhost:8080/axis/services/urn:xmltoday-delayed-quotes</value>
</property>
-->
</bean>


Hope this helps.

Can you post your WSDD aswell?

lucas
Sep 29th, 2004, 09:17 AM
my wsdd file contains the following service configuration:

<service name="PaymentService" provider="java:RPC" style="rpc" use="encoded">
<parameter name="wsdlTargetNamespace" value="urn:payment"/>
<parameter name="wsdlServiceElement" value="PaymentServiceService"/>
<parameter name="wsdlServicePort" value="PaymentService"/>
<parameter name="className" value="myapp.service.ws.server.JaxRpcPaymentService"/>
<parameter name="wsdlPortType" value="PaymentService"/>
<operation name="pay" qname="operNS:pay" xmlns:operNS="urn:payment" returnQName="pay" returnType="rtns:string" xmlns:rtns="http://www.w3.org/2001/XMLSchema" >
<parameter name="in0" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
</operation>
<parameter name="allowedMethods" value="pay"/>
<parameter name="scope" value="Session"/>
</service>

and it is correctly up and running. I tested it with a simple soap client application.

the following is my clientContext.xml:


<beans>
<bean id="jaxRpcProxy" class="org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean">
<property name="serviceInterface">
<value>myapp.service.PaymentService</value>
</property>
<property name="portInterface">
<value>myapp.service.ws.server.RemotePaymentService</value>
</property>

<!--
<property name="serviceFactoryClass">
<value>org.apache.axis.client.ServiceFactory</value>
</property>
-->

<property name="wsdlDocumentUrl">
<value>http://localhost:8080/portal/axis/PaymentService?wsdl</value>
</property>
<property name="namespaceUri">
<value>http://localhost:8080/portal/axis/PaymentService</value>
</property>
<property name="serviceName">
<value>PaymentServiceService</value>
</property>
<property name="portName">
<value>PaymentService</value>
</property>
</bean>
</beans>



It seems to be identical to yours!

ram_2000
Sep 29th, 2004, 11:05 AM
lucas,

The difference i can see is that you specified "wsdlTargetNamespace".

Your spring "namespaceUri" has to match the "wsdlTargetNamespace". Once you do this you also need to specify the "endpointAddress". If you don't specify this, AXIS tries to use the default url (http://localhost:8080/axis/AxisServlet). AXIS is not able to find the Service in this case. Try testing your AXIS Service with a AXIS JAXRPC client without using Spring...You should see the same problem there too..

Try using the following in your spring config:

namespaceUri = urn:payment
endpointAddress = http://localhost:8080/portal/axis/PaymentService

In my case the endpointAddress was "http://localhost:8080/axis/services/<Service name from WSDD>. I don't know how you have setup your web.xml for servlet mappings (default /services/* --> AxisServlet).

ram_2000
Sep 30th, 2004, 11:59 PM
Small correction...I didn't really need the "endpointAddress" attribute. I was playing with tcpmon and changed the port number in the WSDL and forgot about it....When i used the "endpointAddress", everything worked fine and i thought its required. AXIS should be able to use the location in the WSDL service binding section.

igdtl
Nov 12th, 2004, 08:10 AM
Well, it seems that the

javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.xml.rpc.ServiceException: Cannot find service: xxx

thing is a common one. I got that error too trying to invoke a simple Axis web service.

After trying almost all combinations of namespaceUri, endpintAddress, serviceName and portName values; I succedded with a configuration (adapted to your's) similar to:

WSDL:
<?xml version="1.0" encoding="utf-8" ?>
<definitions targetNamespace="urn" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="HelloOperation" />
<message name="HelloOperationResponse">
<part name="return" type="xsd:string" />
</message>
<portType name="HelloWorldService">
<operation name="HelloOperation">
<documentation parameterOrder="">Hello World Method</documentation>
<input message="tns:HelloOperation" />
<output message="tns:HelloOperationResponse" />
</operation>
</portType>
<binding name="HelloWorldService" type="tns:HelloWorldService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http/" />
<operation name="HelloOperation" selector="hello">
<soap:operation soapAction="" />
<input>
<soap:body use="literal" namespace="urn" />
</input>
<output>
<soap:body use="literal" namespace="urn" />
</output>
</operation>
</binding>
<service name="HelloWorldService">
<port name="HelloWorldService" binding="tns:HelloWorldService">
<soap:address location="http://maa5.rmb.co.za:8819/HelloWorldService" />
</port>
</service>
<schemaBindings />
</definitions>

applicationContext.xml:
<beans>
<bean id="HelloWorldService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean">
<property name="serviceFactoryClass"><value>org.apache.axis.client.ServiceFactory</value></property>
<property name="wsdlDocumentUrl"><value>http://maa5.rmb.co.za:8008/HelloWorldServiceMike250.wsdl</value></property>
<property name="namespaceUri"><value>urn</value></property>
<property name="portName"><value>HelloWorldService</value></property>
<property name="serviceName"><value>HelloWorldService</value></property>
<property name="serviceInterface"><value>jaxrpc.HelloWorldService</value></property>
<property name="portInterface"><value>jaxrpc.RemoteHelloWorldService</value></property>
</bean>
</beans>

For the shake of clarity here are listed from where in the WSDL is taken each bean property:

serviceFactoryClass = always org.apache.axis.client.ServiceFactory
wsdlDocumentUrl = the complete URL where the WSLD is located
namespaceUri = /definitions[@targetnamespace]
portName = /definitions/service/port[@name]
serviceName = /definitions/service[@name]
serviceInterface = if you reached this point it shouldn't bee too hard
portInterface = idem

In respect to the endpointAddress attribute I didn't needed it even I had a /definitions/service/port/soap:address[@location] like:

http://maa5.rmb.co.za:8819/mycontext/HelloWorldService

i.e. for an WSDD like:

<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<parameter name="adminPassword" value="admin"/>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="sendXMLDeclaration" value="true"/>
<parameter name="axis.sendMinimizedElements" value="true"/>
<requestFlow>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="session"/>
</handler>
<handler type="java:org.apache.axis.handlers.JWSHandler">
<parameter name="scope" value="request"/>
<parameter name="extension" value=".jwr"/>
</handler>
</requestFlow>
</globalConfiguration>
<handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthentication Handler"/>
<handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponde r"/>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<service name="AdminService" provider="java:MSG">
<parameter name="allowedMethods" value="AdminService"/>
<parameter name="enableRemoteAdmin" value="false"/>
<parameter name="className" value="org.apache.axis.utils.Admin"/>
<namespace>http://xml.apache.org/axis/wsdd/</namespace>
</service>
<service name="Version" provider="java:RPC">
<parameter name="allowedMethods" value="getVersion"/>
<parameter name="className" value="org.apache.axis.Version"/>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
<transport name="local">
<responseFlow>
<handler type="LocalResponder"/>
</responseFlow>
</transport>
</deployment>

Axis generated the following WSDL:

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://localhost:8080/test-spring-jaxrpc/services/Version">
<wsdl:message name="getVersionRequest"></wsdl:message>
<wsdl:message name="getVersionResponse">
<wsdl:part name="getVersionReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="Version">
<wsdl:operation name="getVersion">
<wsdl:input message="impl:getVersionRequest" name="getVersionRequest"/>
<wsdl:output message="impl:getVersionResponse" name="getVersionResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="VersionSoapBinding" type="impl:Version">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getVersion">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getVersionRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://axis.apache.org" use="encoded"/>
</wsdl:input>
<wsdl:output name="getVersionResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/test-spring-jaxrpc/services/Version" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="VersionService">
<wsdl:port binding="impl:VersionSoapBinding" name="Version">
<wsdlsoap:address location="http://localhost:8080/test-spring-jaxrpc/services/Version"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

And the bean definition on the applicationContext.xml configuration file I used was:

<bean id="version" class="org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean">
<property name="serviceFactoryClass"><value>org.apache.axis.client.ServiceFactory</value></property>
<property name="wsdlDocumentUrl"><value>http://localhost:8080/test-spring-jaxrpc/services/Version?wsdl</value></property>
<property name="namespaceUri"><value>http://localhost:8080/test-spring-jaxrpc/services/Version</value></property>
<property name="serviceName"><value>VersionService</value></property>
<property name="portName"><value>Version</value></property>
<property name="serviceInterface"><value>foo.bar.tests.springjaxrpc.server.WebService</value></property>
<property name="portInterface"><value>foo.bar.tests.springjaxrpc.springjaxrpc.server.Rem oteWebService</value></property>
</bean>

Hope it helps, I got mad with this one.

Regards.

Ignacio.