jaxws wsdl common entities - web-services

I want to customize package name of entities used on a webservice. The main objective is to share entities between differents webservice.
I am using jaxws + jaxb to bind entities to their corresponding package.
However, only the ObjectFactory link to the entity is working. It seems that I can't override the use of the wsdl:definition:#targetnamespace for package name.
Here is an example:
I've got a FooBarRemoteService retourning two entities: Foo and Bar. Each of them are #XmlRootElement annotated with a namespace defined (Foo:com.test.foo, Bar:com.test.bar).
Here is the wsdl:
<wsdl:definitions name="FooBarRemoteService" targetNamespace="com.test.foobar" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="com.test.foobar" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http">
<wsdl:types>
<xs:schema elementFormDefault="unqualified" targetNamespace="com.test.foobar" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns2="com.test.bar" xmlns:ns1="com.test.foo">
<xs:import namespace="com.test.foo"/>
<xs:import namespace="com.test.bar"/>
<xs:element name="getBar" type="tns:getBar"/>
<xs:element name="getBarResponse" type="tns:getBarResponse"/>
<xs:element name="getFoo" type="tns:getFoo"/>
<xs:element name="getFooResponse" type="tns:getFooResponse"/>
<xs:complexType name="getFoo">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="getFooResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:foo"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="foo">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="getBar">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="getBarResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:bar"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="bar">
<xs:sequence/>
</xs:complexType>
</xs:schema>
<xs:schema targetNamespace="com.test.foo" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="com.test.foobar">
<xs:import namespace="com.test.foobar"/>
<xs:element name="foo" type="ns1:foo"/>
</xs:schema>
<xs:schema targetNamespace="com.test.bar" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="com.test.foobar">
<xs:import namespace="com.test.foobar"/>
<xs:element name="bar" type="ns1:bar"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="getFooResponse">
<wsdl:part element="tns:getFooResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getFoo">
<wsdl:part element="tns:getFoo" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBarResponse">
<wsdl:part element="tns:getBarResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getBar">
<wsdl:part element="tns:getBar" name="parameters"/>
</wsdl:message>
<wsdl:portType name="InterfaceFooBar">
<wsdl:operation name="getFoo">
<wsdl:input message="tns:getFoo" name="getFoo"/>
<wsdl:output message="tns:getFooResponse" name="getFooResponse"/>
</wsdl:operation>
<wsdl:operation name="getBar">
<wsdl:input message="tns:getBar" name="getBar"/>
<wsdl:output message="tns:getBarResponse" name="getBarResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="FooBarRemoteServiceSoapBinding" type="tns:InterfaceFooBar">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getFoo">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getFoo">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getFooResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getBar">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getBar">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getBarResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="FooBarRemoteService">
<wsdl:port binding="tns:FooBarRemoteServiceSoapBinding" name="FooBar">
<soap:address location="http://localhost:8080/poc/FooBarRemoteService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Here is the binding file
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings version="2.1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
<jaxb:bindings node="wsdl:definitions/wsdl:types/xs:schema[#targetNamespace='com.test.foo']">
<jaxb:schemaBindings>
<jaxb:package name="subpackage.foo" />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings node="wsdl:definitions/wsdl:types/xs:schema[#targetNamespace='com.test.bar']">
<jaxb:schemaBindings>
<jaxb:package name="subpackage.bar" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxws:bindings>
Here is the command to generate java object files:
wsimport ../FooBar.wsdl -b ../binding.xml -verbose
And here are the generated files:
.
|-- foobar
| `-- test
| `-- com
| |-- Bar.class
| |-- FooBarRemoteService.class
| |-- Foo.class
| |-- GetBar.class
| |-- GetBarResponse.class
| |-- GetFoo.class
| |-- GetFooResponse.class
| |-- InterfaceFooBar.class
| |-- ObjectFactory.class
| `-- package-info.class
`-- subpackage
|-- bar
| `-- ObjectFactory.class
`-- foo
`-- ObjectFactory.class
Destination folders are well renamed to subpackage folder. So the binding is taken in account however only ObjectFactory is present. Is their a way to have ObjectFactory with entity depending on it ?
My WSDL was generated with a simple program under wildfly:
Here are my files:
InterfaceFooBar
#WebService(targetNamespace = "com.test.foobar")
public interface InterfaceFooBar {
#WebMethod
public Bar getBar();
#WebMethod
public Foo getFoo();
}
FooBarRemoteService
#WebService(serviceName = "FooBarRemoteService",
portName = "FooBar",
name = "FooBar",
endpointInterface = "poc.interfaces.helloworld.ws.InterfaceFooBar",
targetNamespace = "com.test.foobar")
public class FooBar implements InterfaceFooBar {
#Override
public Bar getBar() {
return new Bar();
}
#Override
public Foo getFoo() {
return new Foo();
}
}
Bar
#XmlRootElement(namespace = "com.test.bar")
#XmlAccessorType(XmlAccessType.FIELD)
public class Bar {
}
Foo
#XmlRootElement(namespace = "com.test.foo")
#XmlAccessorType(XmlAccessType.FIELD)
public class Foo {
}
Thanks by your response.
Regards,
Damien

Ok... I just found the response...
Just change the declaration of Foo and Bar by using #XmlType instead of #XmlRootElement and it is working ...
.
|-- foobar
| `-- test
| `-- com
| |-- FooBarRemoteService.class
| |-- GetBar.class
| |-- GetBarResponse.class
| |-- GetFoo.class
| |-- GetFooResponse.class
| |-- InterfaceFooBar.class
| |-- ObjectFactory.class
| `-- package-info.class
`-- subpackage
|-- bar
| |-- Bar.class
| |-- ObjectFactory.class
| `-- package-info.class
`-- foo
|-- Foo.class
|-- ObjectFactory.class
`-- package-info.class
Damned I spend one day on this :(

Related

I get the following Error: No global element for root was found: {urn:com.companyname.dto}CalloutRequest

I try to implement a SOAP-webservice with spring boot. Everything seems normal until I want to call it. I get the following Message:
No global element for root was found: {urn:com.companyname.dto}CalloutRequest
The wsdl looks the following:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="urn:com.companyname"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:com.companyname"
xmlns:dto="urn:com.companyname.dto">
<wsdl:types>
<xs:schema targetNamespace="urn:com.companyname">
<xs:import schemaLocation="CalloutServiceDto.xsd" namespace="urn:com.companyname.dto"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="CalloutRequestMessage">
<wsdl:part name="request" element="dto:CalloutRequest"></wsdl:part>
</wsdl:message>
<wsdl:message name="CalloutResponseMessage">
<wsdl:part name="response" element="dto:CalloutResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="CalloutPortType">
<wsdl:operation name="callMeldungAusgang">
<wsdl:documentation>Wird eine KVUVMeldung zurueck ins SHIP erzeugt, erfolgt dies ueber diesen Service.
</wsdl:documentation>
<wsdl:input message="tns:CalloutRequestMessage"></wsdl:input>
<wsdl:output message="tns:CalloutResponseMessage"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalloutBinding" type="tns:CalloutPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="callMeldungAusgang">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalloutService">
<wsdl:port name="CalloutPort" binding="tns:CalloutBinding">
<soap:address location="http://localhost:8080/Callout" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="urn:com.companyname.dto"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:com.companyname.dto"
elementFormDefault="qualified">
<xs:element name="CalloutRequest"
type="tns:CalloutRequestType" />
<xs:element name="CalloutResponse"
type="tns:CalloutResponseType" />
<xs:complexType name="CalloutRequestType">
<xs:annotation>
<xs:documentation>
Request fuer einen MeldungsAusgang, welcher ins gesendet wird.
e Beinhaltet nur das Response-XML, gehalten als String.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="xml" type="xs:string" minOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="CalloutResponseType">
<xs:annotation>
<xs:documentation>
Die Antwort der MeldungsAusgangs-Service
</xs:documentation>
</xs:annotation>
</xs:complexType>
</xs:schema>
If I call the webservice he gives me the error that there is no root element. I generate my code with wsdl2java and it works just fine. Just when I call the service via http://localhost:8080/Callout it gives me the error.
Thanks in advance

How to update the WSDL to process a response

Let's have a simple WSDL file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.test.com"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.test.com">
<wsdl:types>
<xs:schema targetNamespace="http://www.test.com">
<xs:element name="sessionId" type="xs:string">
</xs:element>
<xs:element name="transactionId" type="xs:string">
</xs:element>
<xs:element name="Login">
<xs:complexType>
<xs:sequence>
<xs:element name="userId" type="xs:string">
</xs:element>
<xs:element name="pwd" type="xs:string">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="LoginResponse">
<xs:complexType />
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="Login">
<wsdl:part name="parameters" element="Login"/>
</wsdl:message>
<wsdl:message name="LoginResponse">
<wsdl:part name="parameters" element="LoginResponse"/>
</wsdl:message>
<wsdl:message name="HeaderSessionId">
<wsdl:part name="header" element="sessionId"/>
</wsdl:message>
<wsdl:message name="HeaderTransactionId">
<wsdl:part name="header" element="transactionId"/>
</wsdl:message>
<wsdl:portType name="MMCServicesPort">
<wsdl:operation name="Login">
<wsdl:input message="Login"/>
<wsdl:output message="LoginResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MMCServicesBinding" type="MMCServicesPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Login">
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:header message="HeaderSessionId" part="header" use="literal"/>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MMCServicesService">
<wsdl:port name="MMCServicesService" binding="MMCServicesBinding">
<soap:address location="/test"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
For this WSDL the following message is a valid response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:test="http://www.test.com">
<soapenv:Header>
<test:sessionId>xxx</test:sessionId>
</soapenv:Header>
<soapenv:Body>
<test:LoginResponse/>
</soapenv:Body>
</soapenv:Envelope>
What/How do I need to change the WSDL to accept the following message as the Login operation response message instead:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<sessionId xmlns="http://www.test.com">xxx</sessionId>
</soapenv:Header>
<soapenv:Body>
<LoginResponse/>
</soapenv:Body>
</soapenv:Envelope>
...the LoginResponse is w/o a namespace definition.
I have a WS with unknown WSDL which doesn't provide the WSDL. The one above has been somehow reconstructed by someone else in the history. However the real WS which I need to use provides the 2nd response which is however refused by the Apache CXF java library.
Thank you.
The core issue seems to come with the definition of targetNamespace
in your code:
<xs:schema targetNamespace="http://www.test.com">
when replaced with:
<xs:schema targetNamespace="">
the SOAP XML should be without any prefix.
It might require also define the empty or default namespace at the wsdl:binding and wsdl:service level:
<wsdl:binding name="MMCServicesBinding" type="MMCServicesPort" xmlns="">
...
<wsdl:service name="MMCServicesService" xmlns="">
You might have built some code stubs based on that WSDL then you have to update also this generated code.

how to consume a web service in mule flow?

I am beginning with Mule flows. I am trying to consume a webservice in it.
But I am getting some some errors while running.
Error reported by XML parser: Content is not allowed in prolog
Here is my code
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8095" doc:name="HTTP Listener Configuration"/>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="MSCRMDiscoveryService_WSDL.wsdl" service="DiscoveryService" port="CustomBinding_IDiscoveryService" serviceAddress="https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc" doc:name="Web Service Consumer"/>
<data-mapper:config name="Xml_ExecuteResponse__To_Xml_Execute_" transformationGraphPath="xml_executeresponse__to_xml_execute_.grf" doc:name="Xml_ExecuteResponse__To_Xml_Execute_"/>
<data-mapper:config name="Xml_ExecuteResponse__To_Xml_Execute__1" transformationGraphPath="xml_executeresponse__to_xml_execute__1.grf" doc:name="Xml_ExecuteResponse__To_Xml_Execute__1"/>
<flow name="mscrmdiscoveryservice-consumerFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="*" doc:name="HTTP"/>
<data-mapper:transform config-ref="Xml_ExecuteResponse__To_Xml_Execute_" doc:name="Xml<ExecuteResponse> To Xml<Execute>"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="Execute" doc:name="Web Service Consumer"/>
<data-mapper:transform config-ref="Xml_ExecuteResponse__To_Xml_Execute__1" doc:name="Xml<ExecuteResponse> To Xml<Execute>"/>
</flow>
</mule>
wsdl file
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://example.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloWorldService" targetNamespace="http://example.org/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.org/" elementFormDefault="unqualified" targetNamespace="http://example.org/" version="1.0">
<xs:element name="sayHi" type="tns:sayHi"/>
<xs:element name="sayHiResponse" type="tns:sayHiResponse"/>
<xs:complexType name="sayHi">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHiResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="sayHi">
<wsdl:part element="tns:sayHi" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="sayHiResponse">
<wsdl:part element="tns:sayHiResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="HelloWorld">
<wsdl:operation name="sayHi">
<wsdl:input message="tns:sayHi" name="sayHi">
</wsdl:input>
<wsdl:output message="tns:sayHiResponse" name="sayHiResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorldServiceSoapBinding" type="tns:HelloWorld">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sayHi">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="sayHi">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHiResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldService">
<wsdl:port binding="tns:HelloWorldServiceSoapBinding" name="HelloWorldPort">
<soap:address location="http://localhost:8085/hello"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
How can I fix this error?
From the flow you shared, is difficult to tell where the error exactly exists ... It may be your from your wrong XML structure.
Also not clear the use of Datamapper in consuming external web service
The easiest way to consume an existing web service from Mule flow is to prepare/build the soap request for the external service using set payload or XSLT transformer, and then dispatch it through HTTP outbound or HTTP request component.

How To Get Response XML From Generated Stub

I'm using Axis2's wsdl2java to generate a stub for the following WSDL (please note that if names don't match up, it's probably from my obfuscation of the code):
<?xml version="1.0" encoding="UTF-8" standalone="no"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://test.com/saucy/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.com/saucy/definitions" targetNamespace="http://test.com/saucy/definitions">
<wsdl:types>
<xs:schema xmlns:wtfd="http://test.com/saucy/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://test.com/saucy/schemas">
<xs:element name="fubarmanagerRequest">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="1" name="addUsers" type="wtfd:addUsersType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="addUsersType">
<xs:sequence>
<xs:element maxOccurs="unbounded" name="user" type="wtfd:userType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="userType">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="emailAddress" type="xs:string"/>
<xs:element maxOccurs="1" minOccurs="1" name="password" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="fubarmanagerRequest">
<wsdl:part element="sch:fubarmanagerRequest" name="fubarmanagerRequest">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="wtfsaucy">
<wsdl:operation name="fubarmanager">
<wsdl:input message="tns:fubarmanagerRequest" name="fubarmanagerRequest">
</wsdl:input>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="wtfsaucySoap11" type="tns:wtfsaucy">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="fubarmanager">
<soap:operation soapAction=""/>
<wsdl:input name="fubarmanagerRequest">
<soap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="wtfsaucyService">
<wsdl:port binding="tns:wtfsaucySoap11" name="wtfsaucySoap11">
<soap:address location="http://localhost:8080/mailerManagerService/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
However, it seems like the generated stub isn't providing a means for me to retrieve the response XML:
/**
* Auto generated method signature
*
*/
public void fubarManager(com.obfuscated.fubarRequest fubarRequest0
) throws java.rmi.RemoteException
I'm able to get the response XML in SoapUI, but How can I retrieve it through the web generated service client code? Is something missing from my WSDL? Are there additional options I should be passing to wsdl2java?
I had to make sure my WSDL included a section for the response message:
<wsdl:portType name="wtfDirect">
<wsdl:operation name="MailManager">
<wsdl:input message="tns:MailManagerRequest" name="MailManagerRequest">
</wsdl:input>
<wsdl:output message="tns:MailManagerResponse" name="MailManagerResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>

Axis2 : wsdl2java tool Command line

I have this WSDL File already given .
When i used the Axis2 tool wsdl2java -uri StockQuoteService.wsdl
<wsdl:definitions xmlns:axis2="http://quickstart.samples/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns="http://quickstart.samples/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://quickstart.samples/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://quickstart.samples/xsd">
<xs:element name="getPrice">
<xs:complexType>
<xs:sequence>
<xs:element name="symbol" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPriceResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="return" nillable="true" type="xs:double" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="getPriceMessage">
<wsdl:part name="part1" element="ns:getPrice" />
</wsdl:message>
<wsdl:message name="getPriceResponseMessage">
<wsdl:part name="part1" element="ns:getPriceResponse" />
</wsdl:message>
<wsdl:portType name="StockQuoteServicePortType">
<wsdl:operation name="getPrice">
<wsdl:input message="axis2:getPriceMessage" />
<wsdl:output message="axis2:getPriceResponseMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StockQuoteServiceSOAP11Binding" type="axis2:StockQuoteServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<wsdl:operation name="getPrice">
<soap:operation soapAction="urn:getPrice" style="document" />
<wsdl:input>
<soap:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="http://quickstart.samples/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StockQuoteService">
<wsdl:port name="StockQuoteServiceSOAP11port" binding="axis2:StockQuoteServiceSOAP11Binding">
<soap:address
location="http://localhost:8080/axis2/services/StockQuoteService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
What i was expecting is the java code that should be
package samples.quickstart;
import java.util.HashMap;
public class StockQuoteService {
private HashMap map = new HashMap();
public double getPrice(String symbol) {
Double price = (Double) map.get(symbol);
if(price != null){
return price.doubleValue();
}
return 42.00;
}
}
But when i ran wsdl2java -uri StockQuoteService.wsdl
i got this code of java files , where i was expecting the above java file
1.StockQuoteServiceCallbackHandler
2.StockQuoteServiceStub
but not StockQuoteService.java
package samples.quickstart;
import java.util.HashMap;
public class StockQuoteService {
private HashMap map = new HashMap();
public double getPrice(String symbol) {
Double price = (Double) map.get(symbol);
if(price != null){
return price.doubleValue();
}
return 42.00;
}
}
please tell me why so ??
wsdl2java command generates client code to invoke your axis2 service (i.e. Stub and callback handler classes). The business logic inside getPrice() method has nothing to do with your wsdl.