Hi,
Annotation missing cause the error.
The sayHello method in your HelloTest should be
@ResponseWrapper(localName = "sayHelloResponse", targetNamespace =
"http://swebservice.samples.servicemix.apache.org/", className =
"org.apache.servicemix.samples.swebservice.SayHelloResponse")
@RequestWrapper(localName = "sayHello", targetNamespace =
"http://swebservice.samples.servicemix.apache.org/", className =
"org.apache.servicemix.samples.swebservice.SayHello")
@WebResult(name = "return", targetNamespace = "")
@WebMethod
public java.lang.String sayHello(
@WebParam(name = "arg0", targetNamespace = "")
java.lang.String arg0
);
Freeman
jayasreeb wrote:
Hi
I made the annotation changes in HelloTest and HellotestImpl.java as per
your suggesstion.But I am getting following error.
Unmarshalling Error : unexpected element
(uri:"http://swebservice.samples.servicemix.apache.org/", local:"sayHello").
Expected elements are (none)
Actually I am using Java as first way.I have created following
HelloTest.java and HelloImpl.Java first and then using Javatowsdl I am
generating wsdl.
In the pom.xml of Service Unit (Service engine) I have added following entry
to generate wsdl from java..
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf-version}</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-wsdl</id>
<phase>process-classes</phase>
<configuration>
<className>org.apache.servicemix.samples.hello.HelloTest</className>
<verbose>true</verbose>
<outputFile>${project.build.directory}/generated-sources/jaxws/Hello.wsdl</outputFile>
<verbose>true</verbose>
<argline>-classdir ${project.build.directory}/classes</argline>
</configuration>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
</plugin>
Is the entry in pom file is correct?Am I missing something? Do I need to do
any entry in xbean file??
Thanks in advance
Jayasree.B
Freeman Fang wrote:
jayasreeb wrote:
Hi
I created interface HelloTest and and implemenation class
HelloTestImpl.java
HelloTest.java
package org.apache.servicemix.samples.hello;
import javax.jws.WebService;
@WebService(targetNamespace =
"http://swebservice.samples.servicemix.apache.org/")
the annotation here should be
@WebService(targetNamespace
="http://swebservice.samples.servicemix.apache.org/", name="HelloTest")
public interface HelloTest{
public abstract String sayHello(String name);
}
HelloTestImpl.java
package org.apache.servicemix.samples.webservice;
import org.apache.servicemix.samples.hello.*;
import javax.jws.WebService;
@WebService(targetNamespace =
"http://swebservice.samples.servicemix.apache.org/")
the annotation here should be
@WebService(targetNamespace
="http://swebservice.samples.servicemix.apache.org/",
serviceName="HelloTestService",
endpointInterface="org.apache.servicemix.samples.hello.HelloTest" )
Also, since you are using wsdl first way, you should generate code from
wsdl by cxf wsdl2java, cxf tool will take care of annotation for you.
public class HelloTestImpl implements HelloTest{
private String message = "HELLO!!!!!";
public String sayHello(String name) {
return message + name + ".";
}
}
Then by giving following entry in pom file of service unit i generated
wsdl
file from java...
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf-version}</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-wsdl</id>
<phase>process-classes</phase>
<configuration>
<className>org.apache.servicemix.samples.hello.HelloTest</className>
<verbose>true</verbose>
<outputFile>${project.build.directory}/generated-sources/jaxws/Hello.wsdl</outputFile>
<verbose>true</verbose>
<argline>-classdir ${project.build.directory}/classes</argline>
</configuration>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
</plugin>
Jayasree.B
Freeman Fang wrote:
Hi,
I suspect your HelloTestImpl is not annotated correctly, what it looks
like?
Is it inherit from the interface HelloTest.java which you generate using
cxf wsdl2java tool?
Freeman
jayasreeb wrote:
Hi,
Please find my cxf se xbean entry.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0">
<cxfse:endpoint>
<cxfse:pojo>
<bean
class="org.apache.servicemix.samples.webservice.HelloTestImpl" />
</cxfse:pojo>
</cxfse:endpoint>
</beans>
Please find my cxf bc entry
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
xmlns:hello="http://swebservice.samples.servicemix.apache.org/">
<cxfbc:consumer wsdl="classpath:Hello.wsdl"
targetService="hello:HelloTestService"
targetInterface="hello:HelloTest"/>
</beans>
Thanks for your help
Jayasree.B
Freeman Fang wrote:
Hi,
Please append the xbean.xml for your cxf se and cxf bc endpoint.
Freeman
jayasreeb wrote:
Hi,
I have created http web service "Hello" by following "cxf-wsdl-first"
example.I have created a service engine,binding component and service
assembly.I deployed webservice successfully in Servicemix.
When I am giving "http://localhost:9090/hello/?wsdl" in browser
I am successfully getting following wsdl.
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://swebservice.samples.servicemix.apache.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="HelloTestService"
targetNamespace="http://swebservice.samples.servicemix.apache.org/">
- <wsdl:types>
- <xsd:schema attributeFormDefault="unqualified"
elementFormDefault="unqualified"
targetNamespace="http://swebservice.samples.servicemix.apache.org/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://swebservice.samples.servicemix.apache.org/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="sayHello" type="tns:sayHello" />
- <xsd:complexType name="sayHello">
- <xsd:sequence>
<xsd:element minOccurs="0" name="arg0" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="sayHelloResponse" type="tns:sayHelloResponse" />
- <xsd:complexType name="sayHelloResponse">
- <xsd:sequence>
<xsd:element minOccurs="0" name="return" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="sayHello">
<wsdl:part element="tns:sayHello" name="parameters" />
</wsdl:message>
- <wsdl:message name="sayHelloResponse">
<wsdl:part element="tns:sayHelloResponse" name="parameters" />
</wsdl:message>
- <wsdl:portType name="HelloTest">
- <wsdl:operation name="sayHello">
<wsdl:input message="tns:sayHello" name="sayHello" />
<wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse"
/>
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="HelloTestServiceSoapBinding"
type="tns:HelloTest">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="sayHello">
<soap:operation soapAction="" style="document" />
- <wsdl:input name="sayHello">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="sayHelloResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="HelloTestService">
- <wsdl:port binding="tns:HelloTestServiceSoapBinding"
name="HelloTestPort">
<soap:address location="http://localhost:9090/hello/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
My requirement is to invoke this deployed web service from Axis
1.4.So
I
have created Axis client stubs by mentioning the above url and got
the
following classes.I used following command to get the client stubs.
java org.apache.axis.wsdl.WSDL2Java http://localhost:9090/hello/?wsdl
-p
esri.aws.v2006 -v
Following classes got generated :
HelloTest.java
HelloTestService.java
HelloTestServiceLocator.java
HelloTestServiceSoapBindingStub.java
I created a client test class to access the java method sayHello()
which
is
defined in Webservice deployed in Sevicemix.
public class SuccessHelloClient {
public static void main(String args[]){
System.out.println("inside main of client test");
HelloTestService hts = new HelloTestServiceLocator();
//HelloTest ht = hts.getHelloTestPort();
try{
String output = hts.getHelloTestPort().sayHello("sree");
System.out.println("output---"+output);
}catch(Exception e){
System.out.println("inside exception---"+e);
}
}
I got the following error message..
Could not find route for exchange: InOut[
id: ID:10.66.177.114-11adcc83874-2:0
status: Active
role: provider
interface:
{http://swebservice.samples.servicemix.apache.org/}HelloTest
service:
{http://swebservice.samples.servicemix.apache.org/}HelloTestService
operation:
{http://swebservice.samples.servicemix.apache.org/}sayHello
in: <?xml version="1.0" encoding="UTF-8"?><jbi:message
xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper"
xmlns:msg="http://swebservice.samples.servicemix.apache.org/"
name="sayHello" type="msg:sayHello" version="1.0"><jbi:part><sayHello
xmlns="http://swebservice.samples.servicemix.apache.org/"><arg0
xmlns="">sree</arg0></sayHello></jbi:part></jbi:message>
] for service:
{http://swebservice.samples.servicemix.apache.org/}HelloTestService
and
interface:
{http://swebservice.samples.servicemix.apache.org/}HelloTest
Please help me in resolving this as this is on high priority....
I would like to know whether we can invoke Fuse webservice from
AXIS?If
so
what are the steps required to do it?If not what do I need to do to
invoke
Web service deployed in Service mix from stand alone Java Program?
Jayasree.B