Announcement Announcement Module
Collapse
No announcement yet.
javax.xml.rpc.ServiceException: Cannot find service: Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • javax.xml.rpc.ServiceException: Cannot find service:

    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

    Code:
    <beans>
    	<bean id="HelloWorldService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
    		<property name="serviceFactoryClass"><value>org.apache.axis.client.ServiceFactory</value></property>
    		<property name="wsdlDocumentUrl"><value>http&#58;//maa5.rmb.co.za&#58;8008/HelloWorldServiceMike250.wsdl</value></property> 
    		<property name="namespaceUri"><value>http&#58;//maa5.rmb.co.za&#58;8008/HelloWorldServiceMike250</value></property>   
    		<property name="portName"><value>HelloWorldService</value></property>
    		<property name="serviceName"><value>urn&#58;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:

    Code:
    INFO&#58; Creating shared instance of singleton bean 'HelloWorldService'
    2004/09/22 12&#58;29&#58;33 org.springframework.beans.factory.support.AbstractBeanFactory destroySingletons
    INFO&#58; Destroying singletons in factory &#123;org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;HelloWorldService&#93;; Root of BeanFactory hierarchy&#125;
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'HelloWorldService' defined in file &#91;C&#58;\dev\workspace\spring\applicationContext.xml&#93;&#58; Initialization of bean failed; nested exception is javax.xml.rpc.ServiceException&#58; Error processing WSDL document&#58;  
    javax.xml.rpc.ServiceException&#58; Error processing WSDL document&#58;  
    javax.xml.rpc.ServiceException&#58; Cannot find service&#58;  &#123;http&#58;//maa5.rmb.co.za&#58;8008/HelloWorldServiceMike250&#125;urn&#58;HelloWorldService
    javax.xml.rpc.ServiceException&#58; Error processing WSDL document&#58;  
    javax.xml.rpc.ServiceException&#58; Error processing WSDL document&#58;  
    javax.xml.rpc.ServiceException&#58; Cannot find service&#58;  &#123;http&#58;//maa5.rmb.co.za&#58;8008/HelloWorldServiceMike250&#125;urn&#58;HelloWorldService
    	at org.apache.axis.client.Service.initService&#40;Service.java&#58;278&#41;
    	at org.apache.axis.client.Service.<init>&#40;Service.java&#58;193&#41;
    	at org.apache.axis.client.ServiceFactory.createService&#40;ServiceFactory.java&#58;232&#41;
    	at org.springframework.remoting.jaxrpc.LocalJaxRpcServiceFactory.createJaxRpcService&#40;LocalJaxRpcServiceFactory.java&#58;152&#41;
    	at org.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor.afterPropertiesSet&#40;JaxRpcPortClientInterceptor.java&#58;226&#41;
    	at org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean.afterPropertiesSet&#40;JaxRpcPortProxyFactoryBean.java&#58;52&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;801&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;249&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;177&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;159&#41;
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;177&#41;
    	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;268&#41;
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>&#40;FileSystemXmlApplicationContext.java&#58;60&#41;
    	at jaxrpc.ServiceLauncher.bind&#40;ServiceLauncher.java&#58;27&#41;
    	at jaxrpc.ServiceLauncher.main&#40;ServiceLauncher.java&#58;31&#41;
    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:

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

  • #2
    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?

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Code:
          <bean id="jaxrpc" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
              <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&#58;//localhost&#58;8080/axis/services/urn&#58;xmltoday-delayed-quotes?wsdl</value>
              </property>
              <property name="namespaceUri">
                  <value>http&#58;//localhost&#58;8080/axis/services/urn&#58;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&#58;//localhost&#58;8080/axis/services/urn&#58;xmltoday-delayed-quotes</value>
              </property>
          -->
          </bean>
          Hope this helps.

          Can you post your WSDD aswell?

          Comment


          • #6
            my wsdd file contains the following service configuration:
            Code:
              <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:

            Code:
            <beans>
            	<bean id="jaxRpcProxy" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
            		<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!

            Comment


            • #7
              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 = urnayment
              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).

              Comment


              • #8
                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.

                Comment


                • #9
                  Well, it seems that the

                  Code:
                  javax.xml.rpc.ServiceException&#58; Error processing WSDL document&#58; 
                  javax.xml.rpc.ServiceException&#58; Cannot find service&#58;  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:
                  Code:
                  <?xml version="1.0" encoding="utf-8" ?>
                  <definitions targetNamespace="urn" xmlns="http&#58;//schemas.xmlsoap.org/wsdl/" xmlns&#58;soap="http&#58;//schemas.xmlsoap.org/wsdl/soap/" xmlns&#58;tns="urn" xmlns&#58;xsd="http&#58;//www.w3.org/2001/XMLSchema">
                    <message name="HelloOperation" />
                    <message name="HelloOperationResponse">
                      <part name="return" type="xsd&#58;string" />
                    </message>
                    <portType name="HelloWorldService">
                      <operation name="HelloOperation">
                        <documentation parameterOrder="">Hello World Method</documentation>
                        <input message="tns&#58;HelloOperation" />
                        <output message="tns&#58;HelloOperationResponse" />
                      </operation>
                    </portType>
                    <binding name="HelloWorldService" type="tns&#58;HelloWorldService">
                      <soap&#58;binding style="rpc" transport="http&#58;//schemas.xmlsoap.org/soap/http/" />
                      <operation name="HelloOperation" selector="hello">
                        <soap&#58;operation soapAction="" />
                        <input>
                          <soap&#58;body use="literal" namespace="urn" />
                        </input>
                        <output>
                          <soap&#58;body use="literal" namespace="urn" />
                        </output>
                      </operation>
                    </binding>
                    <service name="HelloWorldService">
                      <port name="HelloWorldService" binding="tns&#58;HelloWorldService">
                        <soap&#58;address location="http&#58;//maa5.rmb.co.za&#58;8819/HelloWorldService" />
                      </port>
                    </service>
                    <schemaBindings />
                  </definitions>
                  applicationContext.xml:
                  Code:
                  <beans>
                     <bean id="HelloWorldService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
                        <property name="serviceFactoryClass"><value>org.apache.axis.client.ServiceFactory</value></property>
                        <property name="wsdlDocumentUrl"><value>http&#58;//maa5.rmb.co.za&#58;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:

                  Code:
                  serviceFactoryClass = always org.apache.axis.client.ServiceFactory
                  wsdlDocumentUrl     = the complete URL where the WSLD is located
                  namespaceUri        = /definitions&#91;@targetnamespace&#93;
                  portName            = /definitions/service/port&#91;@name&#93;
                  serviceName         = /definitions/service&#91;@name&#93;
                  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:

                  Code:
                  http&#58;//maa5.rmb.co.za&#58;8819/mycontext/HelloWorldService
                  i.e. for an WSDD like:

                  Code:
                  <?xml version="1.0" encoding="UTF-8"?>
                  <deployment xmlns="http&#58;//xml.apache.org/axis/wsdd/" xmlns&#58;java="http&#58;//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&#58;org.apache.axis.handlers.JWSHandler">
                                  <parameter name="scope" value="session"/>
                              </handler>
                              <handler type="java&#58;org.apache.axis.handlers.JWSHandler">
                                  <parameter name="scope" value="request"/>
                                  <parameter name="extension" value=".jwr"/>
                              </handler>
                          </requestFlow>
                      </globalConfiguration>
                      <handler name="Authenticate" type="java&#58;org.apache.axis.handlers.SimpleAuthenticationHandler"/>
                      <handler name="LocalResponder" type="java&#58;org.apache.axis.transport.local.LocalResponder"/>
                      <handler name="URLMapper" type="java&#58;org.apache.axis.handlers.http.URLMapper"/>
                      <service name="AdminService" provider="java&#58;MSG">
                          <parameter name="allowedMethods" value="AdminService"/>
                          <parameter name="enableRemoteAdmin" value="false"/>
                          <parameter name="className" value="org.apache.axis.utils.Admin"/>
                          <namespace>http&#58;//xml.apache.org/axis/wsdd/</namespace>
                      </service>
                      <service name="Version" provider="java&#58;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&#58;org.apache.axis.handlers.http.HTTPAuthHandler"/>
                          </requestFlow>
                      </transport>
                      <transport name="local">
                          <responseFlow>
                              <handler type="LocalResponder"/>
                          </responseFlow>
                      </transport>
                  </deployment>
                  Axis generated the following WSDL:

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

                  Code:
                  <bean id="version" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
                      <property name="serviceFactoryClass"><value>org.apache.axis.client.ServiceFactory</value></property>
                      <property name="wsdlDocumentUrl"><value>http&#58;//localhost&#58;8080/test-spring-jaxrpc/services/Version?wsdl</value></property>
                      <property name="namespaceUri"><value>http&#58;//localhost&#58;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.RemoteWebService</value></property>
                  </bean>
                  Hope it helps, I got mad with this one.

                  Regards.

                  Ignacio.

                  Comment

                  Working...
                  X