generate EJB from WSDL with wsdl2java - web-services

how do I generate fully annotated Java code from which to implement this sample temperature converter service?
<wsdl:definitions targetNamespace="https://www.w3schools.com/xml/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="https://www.w3schools.com/xml/">
<s:element name="FahrenheitToCelsius">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Fahrenheit" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="FahrenheitToCelsiusResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="FahrenheitToCelsiusResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="CelsiusToFahrenheit">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Celsius" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="CelsiusToFahrenheitResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="CelsiusToFahrenheitResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" nillable="true" type="s:string"/>
</s:schema>
</wsdl:types>
<wsdl:message name="FahrenheitToCelsiusSoapIn">
<wsdl:part name="parameters" element="tns:FahrenheitToCelsius"/>
</wsdl:message>
<wsdl:message name="FahrenheitToCelsiusSoapOut">
<wsdl:part name="parameters" element="tns:FahrenheitToCelsiusResponse"/>
</wsdl:message>
<wsdl:message name="CelsiusToFahrenheitSoapIn">
<wsdl:part name="parameters" element="tns:CelsiusToFahrenheit"/>
</wsdl:message>
<wsdl:message name="CelsiusToFahrenheitSoapOut">
<wsdl:part name="parameters" element="tns:CelsiusToFahrenheitResponse"/>
</wsdl:message>
<wsdl:message name="FahrenheitToCelsiusHttpPostIn">
<wsdl:part name="Fahrenheit" type="s:string"/>
</wsdl:message>
<wsdl:message name="FahrenheitToCelsiusHttpPostOut">
<wsdl:part name="Body" element="tns:string"/>
</wsdl:message>
<wsdl:message name="CelsiusToFahrenheitHttpPostIn">
<wsdl:part name="Celsius" type="s:string"/>
</wsdl:message>
<wsdl:message name="CelsiusToFahrenheitHttpPostOut">
<wsdl:part name="Body" element="tns:string"/>
</wsdl:message>
<wsdl:portType name="TempConvertSoap">
<wsdl:operation name="FahrenheitToCelsius">
<wsdl:input message="tns:FahrenheitToCelsiusSoapIn"/>
<wsdl:output message="tns:FahrenheitToCelsiusSoapOut"/>
</wsdl:operation>
<wsdl:operation name="CelsiusToFahrenheit">
<wsdl:input message="tns:CelsiusToFahrenheitSoapIn"/>
<wsdl:output message="tns:CelsiusToFahrenheitSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="TempConvertHttpPost">
<wsdl:operation name="FahrenheitToCelsius">
<wsdl:input message="tns:FahrenheitToCelsiusHttpPostIn"/>
<wsdl:output message="tns:FahrenheitToCelsiusHttpPostOut"/>
</wsdl:operation>
<wsdl:operation name="CelsiusToFahrenheit">
<wsdl:input message="tns:CelsiusToFahrenheitHttpPostIn"/>
<wsdl:output message="tns:CelsiusToFahrenheitHttpPostOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TempConvertSoap" type="tns:TempConvertSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="FahrenheitToCelsius">
<soap:operation soapAction="https://www.w3schools.com/xml/FahrenheitToCelsius" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="CelsiusToFahrenheit">
<soap:operation soapAction="https://www.w3schools.com/xml/CelsiusToFahrenheit" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TempConvertSoap12" type="tns:TempConvertSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="FahrenheitToCelsius">
<soap12:operation soapAction="https://www.w3schools.com/xml/FahrenheitToCelsius" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="CelsiusToFahrenheit">
<soap12:operation soapAction="https://www.w3schools.com/xml/CelsiusToFahrenheit" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="TempConvertHttpPost" type="tns:TempConvertHttpPost">
<http:binding verb="POST"/>
<wsdl:operation name="FahrenheitToCelsius">
<http:operation location="/FahrenheitToCelsius"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="CelsiusToFahrenheit">
<http:operation location="/CelsiusToFahrenheit"/>
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded"/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TempConvert">
<wsdl:port name="TempConvertSoap" binding="tns:TempConvertSoap">
<soap:address location="http://www.w3schools.com/xml/tempconvert.asmx"/>
</wsdl:port>
<wsdl:port name="TempConvertSoap12" binding="tns:TempConvertSoap12">
<soap12:address location="http://www.w3schools.com/xml/tempconvert.asmx"/>
</wsdl:port>
<wsdl:port name="TempConvertHttpPost" binding="tns:TempConvertHttpPost">
<http:address location="http://www.w3schools.com/xml/tempconvert.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
This is what I've generated through Netbeans by clicking "new web service from WSDL":
package net.bounceme.dur.wsdl.consume;
import javax.ejb.Stateless;
import javax.xml.ws.ServiceMode;
import javax.xml.ws.WebServiceProvider;
#Stateless
#ServiceMode(value = javax.xml.ws.Service.Mode.PAYLOAD)
#WebServiceProvider(serviceName = "TempConvert", portName = "TempConvertSoap", targetNamespace = "https://www.w3schools.com/xml/", wsdlLocation = "WEB-INF/wsdl/NewWebServiceFromWSDL1/www.w3schools.com/xml/tempconvert.asmx.wsdl")
public class TempConvertFromWSDL implements javax.xml.ws.Provider<javax.xml.transform.Source> {
#Override
public javax.xml.transform.Source invoke(javax.xml.transform.Source source) {
throw new UnsupportedOperationException("Not implemented yet.");
}
}
This code seems lacking.
(Notably, at least to me, is that the URL isn't quite, exactly, matched in the generated annotations for the class.)
This is in order to inject into a Servlet.

Related

Changing default Content-Type in SOAP body through WSDL

I have created a web service using Axis2 and I want to change the Content-type of my response from text/xml; charset=UTF-8 to text/xml; charset=utf-8.
Only when I send the Content-type as text/xml; charset=utf-8 in request header, it returns corretly. But in my case, I don't have that flexibility. So, I need to find a way to change th default Content-Type to text/xml; charset=utf-8.
Can some one give an idea on how to change this?
I have tried below like options but no any luck.
WSDL :
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="GradeTenMathService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xs:schema>
<xs:import namespace="http://tempuri.org/" schemaLocation="Math.xsd"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="AdditionResponse">
<wsdl:part name="AdditionRS" element="tns:AdditionResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="AdditionRequest">
<wsdl:part name="AdditionRQ" element="tns:AdditionRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="DevisionResponse">
<wsdl:part name="DevisionRS" element="tns:DevisionResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="DevisionRequest">
<wsdl:part name="DevisionRQ" element="tns:DevisionRequest">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="GradeTenMathPortType">
<wsdl:operation name="Addition">
<wsdl:input message="tns:AdditionRequest">
</wsdl:input>
<wsdl:output message="tns:AdditionResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Devision">
<wsdl:input message="tns:DevisionRequest">
</wsdl:input>
<wsdl:output message="tns:DevisionResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="GradeTenMathBinding" type="tns:GradeTenMathPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Addition">
<soap:operation soapAction="Addition" style="document"/>
<wsdl:input>
<mime:content part="Addition" type="text/xml; charset=utf-8"/>
</wsdl:input>
<wsdl:output>
<mime:content part="Addition" type="text/xml; charset=utf-8"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Devision">
<soap:operation soapAction="Devision" style="document"/>
<wsdl:input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="GradeTenMath">
<wsdl:port name="GradeTenMathPort" binding="tns:GradeTenMathBinding">
<soap:address location="http://localhost:8081/axis2/services/GradeTenMath"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

The endpoint reference (EPR) for the Operation not found

I started learning Web Services. I wrote my first piece of code from the example that was given in the book. But when i run it, it does not behanve the way its supposed to! I see the wsdl file generated and see the error:
My WSDL file is:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://ts.ch01" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://ts.ch01" xmlns:intf="http://ts.ch01" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://ts.ch01" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getTimeAsString">
<complexType/>
</element>
<element name="getTimeAsStringResponse">
<complexType>
<sequence>
<element name="getTimeAsStringReturn" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="getTimeAsElapsed">
<complexType/>
</element>
<element name="getTimeAsElapsedResponse">
<complexType>
<sequence>
<element name="getTimeAsElapsedReturn" type="xsd:long"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="getTimeAsStringResponse">
<wsdl:part element="impl:getTimeAsStringResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getTimeAsElapsedResponse">
<wsdl:part element="impl:getTimeAsElapsedResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getTimeAsElapsedRequest">
<wsdl:part element="impl:getTimeAsElapsed" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getTimeAsStringRequest">
<wsdl:part element="impl:getTimeAsString" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="WSNewTestImpl">
<wsdl:operation name="getTimeAsString">
<wsdl:input message="impl:getTimeAsStringRequest" name="getTimeAsStringRequest">
</wsdl:input>
<wsdl:output message="impl:getTimeAsStringResponse" name="getTimeAsStringResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getTimeAsElapsed">
<wsdl:input message="impl:getTimeAsElapsedRequest" name="getTimeAsElapsedRequest">
</wsdl:input>
<wsdl:output message="impl:getTimeAsElapsedResponse" name="getTimeAsElapsedResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WSNewTestImplSoapBinding" type="impl:WSNewTestImpl">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getTimeAsString">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getTimeAsStringRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getTimeAsStringResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getTimeAsElapsed">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getTimeAsElapsedRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getTimeAsElapsedResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WSNewTestImplService">
<wsdl:port binding="impl:WSNewTestImplSoapBinding" name="WSNewTestImpl">
<wsdlsoap:address location="http://localhost:9090/WSTestOther/services/WSNewTestImpl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I am not sure what other information to provide, if you need anything just ask. I am using Tomcat 7.0
Also I see the error in console:
[ERROR] The endpoint reference (EPR) for the Operation not found is /WSTestOther/services/WSNewTestImplService and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.
org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /WSTestOther/services/WSNewTestImplService and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.
at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:102)
at org.apache.axis2.engine.Phase.invoke(Phase.java:329)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:168)
at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:144)
at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:139)
at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:837)
at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:273)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
[WARN] Deprecated usage of OMElement#declareNamespace(String,String) with empty prefix

Please advise on the WSDL

I have created a WSDL to create a greeting service. Given below is the WSDL.
I am using thsi wsdl to create a generate and expose a web-service using the cxf:proxy-service in mule.
This is giving me errors.
Please review and help me undertand what is the problem with this WSDL.
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="HelloService"
targetNamespace="http://example.org/HelloService"
xmlns:tns="http://example.org/HelloService"
xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://example.org/HelloService" >
<xsd:element name="LastName">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="lName" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="FirstName">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="fName" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Greeting">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="greet" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="shortRequest">
<wsdl:part type="tns:LastName" name="lastName"/>
</wsdl:message>
<wsdl:message name="fullRequest">
<wsdl:part type="tns:FirstName" name="firstName"/>
<wsdl:part type="tns:LastName" name="lastName"/>
</wsdl:message>
<wsdl:message name="greetingResponse">
<wsdl:part type="tns:greeting" name="greetings"/>
</wsdl:message>
<wsdl:portType name="HelloServicePortType">
<wsdl:operation name="simpleGreeting">
<wsdl:input message="tns:shortRequest" name="shortRequest" />
<wsdl:output message="tns:greetingResponse" name="greetingResponse" />
</wsdl:operation>
<wsdl:operation name="fullGreeting">
<wsdl:input message="tns:fullRequest" name="fullRequest" />
<wsdl:output message="tns:greetingResponse" name="greetingResponseFull" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloServiceSOAP" type="tns:HelloServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="simpleGreeting">
<soap:operation soapAction="" style="document" />
<wsdl:input name="shortRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="greetingResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="fullGreeting">
<soap:operation soapAction="" style="document" />
<wsdl:input name="fullRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="greetingResponseFull">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ProxyService">
<wsdl:port binding="tns:HelloServiceSOAP" name="HelloServiceSOAPB">
<soap:address location="http://localhost:8080/HelloService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Please help me if there is something wrong in my WSDL.
It is not working when I use it in mule cxf:proxy-service.
FGiven below si the Mule Flow which is using this WSDL to expose service.
<flow name="WS_In">
<http:inbound-endpoint address="http://localhost:8080/HelloService" exchange-pattern="request-response">
<cxf:proxy-service wsdlLocation="classpath:globalid3.wsdl" namespace="http://example.org/HelloService" service="ProxyService" />
</http:inbound-endpoint>
<component>
<prototype-object class="com.example.ServiceProxy">
</prototype-object>
</component>
<echo-component></echo-component>
<logger level="INFO" />
</flow>
and the Error is :
org.mule.api.lifecycle.LifecycleException: Lifecycle Manager 'WS_In.stage1' phase 'start' does not support phase 'dispose'
at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:156)
There is a casing issue in your WSDL. Instead of:
<wsdl:message name="greetingResponse">
<wsdl:part type="tns:greeting" name="greetings"/>
</wsdl:message>
you should have:
<wsdl:message name="greetingResponse">
<wsdl:part type="tns:Greeting" name="greetings"/>
</wsdl:message>
With this fixed, the following produces a web service that works fine when called from SOAPui:
<flow name="WS_In">
<http:inbound-endpoint address="http://localhost:8080/HelloService"
exchange-pattern="request-response">
<cxf:proxy-service wsdlLocation="classpath:globalid3.wsdl"
namespace="http://example.org/HelloService" service="ProxyService" />
</http:inbound-endpoint>
<custom-processor class="com.example.ServiceProxy" />
</flow>
Message processor:
package com.example;
import javax.xml.namespace.QName;
import org.apache.commons.lang.StringEscapeUtils;
import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.api.processor.MessageProcessor;
public class ServiceProxy implements MessageProcessor
{
private final static QName SIMPLE_GREETING = new QName("http://example.org/HelloService",
"simpleGreeting");
public MuleEvent process(final MuleEvent event) throws MuleException
{
final QName operation = event.getFlowVariable("cxf_operation");
if (operation.equals(SIMPLE_GREETING))
{
final String lastName = event.getMuleContext()
.getExpressionLanguage()
.evaluate("xpath('/lastName').text", event);
final String responseXml = "<greetings><greet>Hi " + StringEscapeUtils.escapeXml(lastName)
+ "</greet></greetings>";
event.getMessage().setPayload(responseXml);
return event;
}
throw new UnsupportedOperationException(operation.getLocalPart() + " " + operation.getNamespaceURI()
+ " " + operation.getPrefix());
}
}
There is one way to do this using cxf:jaxws-service, but you'll need to generate the service class. Take a look here on how to do this.
After that you can configure the service in a very simple way.
<cxf:jaxws-service
serviceClass="mypackage.webservices.MyServicePortType"
validationEnabled="false">
</cxf:jaxws-service>
The flow that is working is as below.
<flow name="WS_In">
<http:inbound-endpoint address="http://localhost:8080/HelloService" exchange-pattern="request-response">
<cxf:proxy-service wsdlLocation="classpath:helloservice.wsdl" namespace="http://example.org/HelloService" service="ProxyService" />
</http:inbound-endpoint>
<component>
<prototype-object class="com.example.ServiceProxy">
</prototype-object>
</component>
<echo-component></echo-component>
<logger level="INFO" />
</flow>
And the WSDL is
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="HelloService"
targetNamespace="http://example.org/HelloService"
xmlns:tns="http://example.org/HelloService"
xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="shortRequest">
<wsdl:part type="xsd:string" name="lastName"/>
</wsdl:message>
<wsdl:message name="fullRequest">
<wsdl:part type="xsd:string" name="firstName"/>
<wsdl:part type="xsd:string" name="lastName"/>
</wsdl:message>
<wsdl:message name="greetingResponse">
<wsdl:part type="xsd:string" name="greetings"/>
</wsdl:message>
<wsdl:portType name="HelloServicePortType">
<wsdl:operation name="simpleGreeting">
<wsdl:input message="tns:shortRequest" name="shortRequest" />
<wsdl:output message="tns:greetingResponse" name="greetingResponse" />
</wsdl:operation>
<wsdl:operation name="fullGreeting">
<wsdl:input message="tns:fullRequest" name="fullRequest" />
<wsdl:output message="tns:greetingResponse" name="greetingResponseFull" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloServiceSOAP" type="tns:HelloServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="simpleGreeting">
<soap:operation soapAction="" style="document" />
<wsdl:input name="shortRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="greetingResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="fullGreeting">
<soap:operation soapAction="" style="document" />
<wsdl:input name="fullRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="greetingResponseFull">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ProxyService">
<wsdl:port binding="tns:HelloServiceSOAP" name="HelloServiceSOAPB">
<soap:address location="http://localhost:8080/HelloService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Thanks everyone for your help and support.

Why java2wsdl from axis2 produce not valid wsdl

Why java2wsdl from axis2 produce wsdl not validated by Altova XmlSpy?
I got error
attribute 'part' in extensibility element '<mime:content>' refers to part 'myMethod' which could not be found in message 'myMethodRequest'
Error location: wsdl:definitions / wsdl:binding / wsdl:operation / wsdl:input / mime:content / #part
Where is the bug?
axis2 version 1.5.4
Altova XmlSpy version 2011 rel2
Sample Class:
package my.pkg;
public class SampleWs {
public String myMethod(String objectId) {
return objectId;
}
}
Sample generated wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://pkg.my" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://pkg.my">
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pkg.my">
<xs:element name="myMethod">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="objectId" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="myMethodResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="myMethodRequest">
<wsdl:part name="parameters" element="ns:myMethod"/>
</wsdl:message>
<wsdl:message name="myMethodResponse">
<wsdl:part name="parameters" element="ns:myMethodResponse"/>
</wsdl:message>
<wsdl:portType name="SampleWsPortType">
<wsdl:operation name="myMethod">
<wsdl:input message="ns:myMethodRequest" wsaw:Action="urn:myMethod"/>
<wsdl:output message="ns:myMethodResponse" wsaw:Action="urn:myMethodResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SampleWsSoap11Binding" type="ns:SampleWsPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="myMethod">
<soap:operation soapAction="urn:myMethod" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SampleWsSoap12Binding" type="ns:SampleWsPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="myMethod">
<soap12:operation soapAction="urn:myMethod" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="SampleWsHttpBinding" type="ns:SampleWsPortType">
<http:binding verb="POST"/>
<wsdl:operation name="myMethod">
<http:operation location="SampleWs/myMethod"/>
<wsdl:input>
<mime:content type="text/xml" part="myMethod"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="myMethod"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SampleWs">
<wsdl:port name="SampleWsHttpSoap11Endpoint" binding="ns:SampleWsSoap11Binding">
<soap:address location="http://localhost:8080/axis2/services/SampleWs"/>
</wsdl:port>
<wsdl:port name="SampleWsHttpSoap12Endpoint" binding="ns:SampleWsSoap12Binding">
<soap12:address location="http://localhost:8080/axis2/services/SampleWs"/>
</wsdl:port>
<wsdl:port name="SampleWsHttpEndpoint" binding="ns:SampleWsHttpBinding">
<http:address location="http://localhost:8080/axis2/services/SampleWs"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
It seems bug in axis2 java2wsdl version 1.5.4
Switched to 1.6.2 version - now all OK

versioning of wsdl contracts

Can Anyone tell me way to version Wsdl contracts(wsdl first service) for major and minor versions.any running example will be very helpful.
The way I m following to version my wsdl is this.I am following Iona webservices versioning guidlines
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="ProductServiceImplServicev2"
targetNamespace="http://service.dtechtalkcenter.com/servicev2"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://service.dtechtalkcenter.com/servicev2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" `enter code here`
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:v2_0="http://service.dtechtalkcenter.com/servicev2.0"
xmlns:v2_1="http://service.dtechtalkcenter.com/servicev2.1">
<wsdl:types>
<xsd:schema elementFormDefault="unqualified" targetNamespace="http://service.dtechtalkcenter.com/servicev2.0">
<xsd:element name="addProduct" type="v2_0:addProduct"/>
<xsd:element name="addProductResponse" type="v2_0:addProductResponse"/>
<xsd:element name="getProducts" type="v2_0:getProducts"/>
<xsd:element name="getProductsResponse" type="v2_0:getProductsResponse"/>
<xsd:complexType name="getProducts">
<xsd:sequence/>
</xsd:complexType>
<xsd:complexType name="getProductsResponse">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="return" type="v2_0:product"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="product">
<xsd:sequence>
<xsd:element name="cast" type="xsd:double"/>
<xsd:element minOccurs="0" name="productCategory" type="xsd:string"/>
<xsd:element minOccurs="0" name="productDetails" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="addProduct">
<xsd:sequence>
<xsd:element minOccurs="0" name="product" type="v2_0:product"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="addProductResponse">
<xsd:sequence/>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="addProductResponse">
<wsdl:part name="parameters" element="v2_0:addProductResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getProducts">
<wsdl:part name="parameters" element="v2_0:getProducts">
</wsdl:part>
</wsdl:message>
<wsdl:message name="addProduct">
<wsdl:part name="parameters" element="v2_0:addProduct">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getProductsResponse">
<wsdl:part name="parameters" element="v2_0:getProductsResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ProductService_v2_0">
<wsdl:operation name="getProducts">
<wsdl:input name="getProducts" message="tns:getProducts">
</wsdl:input>
<wsdl:output name="getProductsResponse" message="tns:getProductsResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addProduct">
<wsdl:input name="addProduct" message="tns:addProduct">
</wsdl:input>
<wsdl:output name="addProductResponse" message="tns:addProductResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ProductServiceImplService_v2_0_SoapBinding" type="tns:ProductService_v2_0">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getProducts">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getProducts">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getProductsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="addProduct">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="addProduct">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="addProductResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ProductServiceImplService_v2_0">
<wsdl:port name="ProductServiceImplPort" binding="tns:ProductServiceImplService_v2_0_SoapBinding">
<soap:address location="http://localhost:8088/VersionService/services/ProductServiceImplPort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>