I am trying to develop a Soap web service, I created a UsersWS.wsdl file and now I need to generate the UsersWS interface to implements my UserWSImpl.java class. I tried some tutorials and plugins but nothing worked for me, can anyone help me ?
this is my POM.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.o7planning</groupId>
<artifactId>JAXWSSoapWebServiceTutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>JAXWSSoapWebServiceTutorial Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<cxf-version>3.5.4</cxf-version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<build>
<finalName>JAXWSSoapWebServiceTutorial</finalName>
<pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.4</version>
<configuration>
<goalPrefix>plugin</goalPrefix>
<outputDirectory>target/dir</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/UsersWS.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
and this is my UsersWS.wsdl file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/NewWSDLFile/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="UsersWS" targetNamespace="http://www.example.org/NewWSDLFile/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/NewWSDLFile/">
<xsd:element name="AddUser">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AddUserResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeleteUser">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeleteUserResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeleteUserFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="DeleteUserFault"
type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetUser">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetUserResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="UpdateUser">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="UpdateUserResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetAllUsers">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GetAllUsersResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="AddUserRequest">
<wsdl:part name="parameters" element="tns:AddUser"></wsdl:part>
</wsdl:message>
<wsdl:message name="AddUserResponse">
<wsdl:part name="parameters" element="tns:AddUserResponse"></wsdl:part>
</wsdl:message>
<wsdl:message name="DeleteUserRequest">
<wsdl:part name="parameters" element="tns:DeleteUser"></wsdl:part>
</wsdl:message>
<wsdl:message name="DeleteUserResponse">
<wsdl:part name="parameters" element="tns:DeleteUserResponse"></wsdl:part>
</wsdl:message>
<wsdl:message name="DeleteUserFault">
</wsdl:message>
<wsdl:message name="GetUserRequest">
<wsdl:part name="parameters" element="tns:GetUser"></wsdl:part>
</wsdl:message>
<wsdl:message name="GetUserResponse">
<wsdl:part name="parameters" element="tns:GetUserResponse"></wsdl:part>
</wsdl:message>
<wsdl:message name="UpdateUserRequest">
<wsdl:part name="parameters" element="tns:UpdateUser"></wsdl:part>
</wsdl:message>
<wsdl:message name="UpdateUserResponse">
<wsdl:part name="parameters" element="tns:UpdateUserResponse"></wsdl:part>
</wsdl:message>
<wsdl:message name="GetAllUsersRequest">
<wsdl:part name="parameters" element="tns:GetAllUsers"></wsdl:part>
</wsdl:message>
<wsdl:message name="GetAllUsersResponse">
<wsdl:part name="parameters" element="tns:GetAllUsersResponse"></wsdl:part>
</wsdl:message>
<wsdl:portType name="UsersWS">
<wsdl:operation name="AddUser">
<wsdl:input message="tns:AddUserRequest"></wsdl:input>
<wsdl:output message="tns:AddUserResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="DeleteUser">
<wsdl:input message="tns:DeleteUserRequest"></wsdl:input>
<wsdl:output message="tns:DeleteUserResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="UpdateUser">
<wsdl:input message="tns:UpdateUserRequest"></wsdl:input>
<wsdl:output message="tns:UpdateUserResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetAllUsers">
<wsdl:input message="tns:GetAllUsersRequest"></wsdl:input>
<wsdl:output message="tns:GetAllUsersResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="UsersWSSOAP" type="tns:UsersWS">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="AddUser">
<soap:operation soapAction="http://www.example.org/NewWSDLFile/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="UsersWS">
<wsdl:port binding="tns:UsersWSSOAP" name="UsersWSSOAP">
<soap:address location="http://www.example.org/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
What am I missing?
Related
I have a perl program that is accessing a soap server. when testing the soap server via SoapUI it works, but when using my perl program I get
Can't use an undefined value as an ARRAY reference at /Library/Perl/5.18/SOAP/WSDL.pm line 222.
Here is my perl script.
use SOAP::WSDL;
my $data = 'some data here';
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $client = SOAP::WSDL->new( 'wsdl' => "link_to_wsdl" );
my $result = $client->call('MyMethod', $data);
use Data::Dumper;
print Dumper($result);
Here is the WSDL
<?xml version="1.0"?>
<wsdl:definitions
name="Test"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:APISoapServer"
targetNamespace="urn:APISoapServer"
>
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:APISoapServer">
<xsd:element name="MyMethod">
<xsd:complexType>
<xsd:complexContent mixed="true">
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="operand1" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="MyMethodResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Confirmation" maxOccurs="unbounded">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="response" type="xsd:string"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MYAPIRequest">
<wsdl:part name="MYAPIRequestPart" element="tns:MyMethod"/>
</wsdl:message>
<wsdl:message name="MYAPIResponse">
<wsdl:part name="MYAPIResponsePart" element="tns:MyMethodResponse"/>
</wsdl:message>
<wsdl:portType name="MYAPIServerPort">
<wsdl:operation name="MyMethod">
<wsdl:input name="MyMethodInput" message="tns:MYAPIRequest"/>
<wsdl:output name="MyMethodOutput" message="tns:MYAPIResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MYAPIServerBinding" type="tns:MYAPIServerPort">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="MyMethod">
<soap12:operation style="document" soapAction="urn:APISoapServer#MyMethod" />
<wsdl:input name="MyMethodInput">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="MyMethodOutput">
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="MYAPIService">
<wsdl:port name="MYAPIPort" binding="tns:MYAPIServerBinding">
<soap12:address location="https://my.site.com/api/my_api_server.pl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I am trying to write a simple wsdl file that has a inline xsd. But I'm getting the below errors marked with '*' in wsdl file. I refered other Stack Overflow question, but none helped on this issue.I've just edited my xsd and wsdl file to include the namespaces in each for more details on the files. You may please note that this are files are I've created in my local machine.Below is my code.
xsd file:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/bookService" xmlns:tns="http://www.example.org/bookService" elementFormDefault="qualified">
<element name="BookServiceRequest"
type="tns:BookServiceRequestType">
</element>
<complexType name="BookServiceRequestType">
<sequence>
<element name="limit" type="int"></element>
</sequence>
</complexType>
<complexType name="BookServiceResponseType">
<sequence>
<element name="book" type="tns:BookType" maxOccurs="unbounded" minOccurs="0"></element>
</sequence>
</complexType>
<element name="BookServiceResponse"
type="tns:BookServiceResponseType">
</element>
<complexType name="BookType">
<sequence>
<element name="title" type="string" maxOccurs="1" minOccurs="1"></element>
<element name="author" type="string" maxOccurs="1" minOccurs="1"></element>
<element name="published" type="date" maxOccurs="1" minOccurs="1"></element>
</sequence>
</complexType>
</schema>
wsdl file:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="bookService"
targetNamespace="http://www.example.org/bookService/" xmlns:tns="http://www.example.org/bookService/"
xmlns:wsdl="http://www.example.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/bookService/">
<xsd:import schemaLocation="../schema/bookService.xsd"
namespace="http://www.example.org/bookService/" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="BookServiceRequest">
**<wsdl:part name="BookServiceRequest" element="tns:BookServiceRequest" />
</wsdl:message>**
<wsdl:message name="BookServiceResponse">
**<wsdl:part name="BookServiceResponse" element="tns:BookServiceResponse" />**
</wsdl:message>
<wsdl:portType name="BookServicePortType">
<wsdl:operation name="fetchBooks">
<wsdl:input name="BookServiceRequest" message="tns:BookServiceRequest" />
<wsdl:output name="BookServiceResponse" message="tns:BookServiceResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BookServiceBinding" type="tns:BookServicePortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="fetchBooks">
<soap:operation style="document"
soapAction="http://www.example.org/bookService/fetchBooks" />
<wsdl:input name="BookServiceRequest">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="BookServiceResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="BookService">
<wsdl:port name="BookServicePort" binding="tns:BookServiceBinding">
<soap:address location="/service/bookService" />
</wsdl:port>
</wsdl:service>
I am trying to generate the web service client from WSDL , I am quiet new to this so can't figure out the error.
I have tried:
wsimport -keep path-to-wsdl
which gives me this error :
C:\WINDOWS\system32>wsimport -keep E:\NIEsocketWork\sdl.wsdl
parsing WSDL...
[WARNING] src-resolve.4.2: Error resolving component 'tns:GetMerchantRateRequest'. It was detected that 'tns:GetMerchantRateRequest' is in namespace 'http://www.fexcodcc.com/DCC20071126', but components from this namespace are not referenceable from schema document 'file:/E:/NIEsocketWork/sdl.wsdl#types?schema1'. If this is the incorrect namespace, perhaps the prefix of 'tns:GetMerchantRateRequest' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/E:/NIEsocketWork/sdl.wsdl#types?schema1'.
line 20 of file:/E:/NIEsocketWork/sdl.wsdl#types?schema1
[WARNING] src-resolve: Cannot resolve the name 'tns:GetMerchantRateRequest' to a(n) 'type definition' component.
line 20 of file:/E:/NIEsocketWork/sdl.wsdl#types?schema1
[ERROR] undefined simple or complex type 'tns:GetMerchantRateRequest'
line 20 of file:/E:/NIEsocketWork/sdl.wsdl
[ERROR] undefined simple or complex type 'tns:GetMerchantRateResponse'
line 26 of file:/E:/NIEsocketWork/sdl.wsdl
[ERROR] undefined simple or complex type 'tns:GetCardRateRequest'
line 79 of file:/E:/NIEsocketWork/sdl.wsdl
[ERROR] undefined simple or complex type 'tns:GetCardRateResponse'
line 85 of file:/E:/NIEsocketWork/sdl.wsdl
Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException
at com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:129)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2283)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:183)
at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:126)
at com.sun.tools.internal.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:429)
at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:190)
at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:168)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)
I have also tried apache cxf 3.1.1 to generate the web service client in eclipse but get this error :
Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -client -d C:\Users\Hamza\GalileoWorkspace\NIDCCFexco\.cxftmp/src -classdir C:\Users\Hamza\GalileoWorkspace\NIDCCFexco\build\classes -p http://www.fexcodcc.com/DCC20071126=com.fexcodcc.dcc20071126 -impl -validate -exsh false -dns true -dex true -wsdlLocation file:///E:/NIEsocketWork/sdl.wsdl -verbose -defaultValues -fe jaxws -db jaxb -wv 1.1 file:/E:/NIEsocketWork/sdl.wsdl
wsdl2java - Apache CXF 3.1.1
WSDLToJava Error:
Summary: Failures: 4, Warnings: 0
<<< ERROR!
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRate> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRate> can not be found in the schemas
org.apache.cxf.tools.common.ToolException:
Summary: Failures: 4, Warnings: 0
<<< ERROR!
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRate> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRate> can not be found in the schemas
at org.apache.cxf.tools.validator.internal.WSDL11Validator.isValid(WSDL11Validator.java:139)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.validate(JAXWSDefinitionBuilder.java:207)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:204)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:415)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
My WSDL file is :
<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions targetNamespace="http://www.fexcodcc.com/DCC20071126"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://www.fexcodcc.com/DCC20071126"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation>DCC Gateway (Provides functionality to make requests to the DCC for availability)</wsdl:documentation>
<!-- Types --> <wsdl:types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http:// www.fexcodcc.com/DCC20071126" xmlns:dhs="urn:dhs">
<!-- Type definitions -->
<xsd:element name="GetMerchantRate"> <xsd:complexType>
<xsd:sequence>
<xsd:element name="GetMerchantRateRequest" type="tns:GetMerchantRateRequest" minOccurs="1" maxOccurs="1"/>
</xsd:sequence> </xsd:complexType>
</xsd:element>
<xsd:element name="GetMerchantRateResult"> <xsd:complexType>
<xsd:sequence>
<xsd:element name="GetMerchantRateResponse" type="tns:GetMerchantRateResponse" minOccurs="1" maxOccurs="1" />
</xsd:sequence> </xsd:complexType>
</xsd:element>
<!-- Complex type definitions -->
<xsd:complexType name="GetMerchantRateResponse"> <xsd:sequence>
<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ExchangeRate" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="FgnCurCode" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="FgnAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="DccOffered" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ValidHours" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="MarginRatePercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ExchangeRateSourcename" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="CommissionPercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ExchangerateSourceTimestamp" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="MinorUnits" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ResponseCode" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence> </xsd:complexType>
<xsd:complexType name="GetMerchantRateRequest"> <xsd:sequence>
<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="MerchantId" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Acquirer" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="FgnCurCode" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="BaseAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence> </xsd:complexType>
<xsd:element name="GetCardRate"> <xsd:complexType>
<xsd:sequence>
<xsd:element name="GetCardRateRequest" type="tns:GetCardRateRequest" minOccurs="1" maxOccurs="1" />
</xsd:sequence> </xsd:complexType>
</xsd:element>
<xsd:element name="GetCardRateResult"> <xsd:complexType>
<xsd:sequence>
<xsd:element name ="GetCardRateResponse" type="tns:GetCardRateResponse" minOccurs="1" maxOccurs="1" />
</xsd:sequence> </xsd:complexType>
</xsd:element>
<!-- Complex type definitions --> <xsd:complexType name="GetCardRateResponse">
<xsd:sequence>
<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ExchangeRate" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="FgnCurCode" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="FgnAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="DccOffered" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ValidHours" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="MarginRatePercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ExchangeRateSourceName" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="CommissionPercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ExchangeRateSourceTimestamp" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="MinorUnits" type="xsd:string" minOccurs="0" maxOccurs="1" /><xsd:element name="ResponseCode" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence> </xsd:complexType>
<xsd:complexType name="GetCardRateRequest"> <xsd:sequence>
<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="CardId" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="MerchantId" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="Acquirer" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="BaseAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence> </xsd:complexType>
</xsd:schema> </wsdl:types>
<!-- Dhs Server Messages --> <wsdl:message name="GetMerchantRateIn">
<wsdl:part name="parameters" element="tns:GetMerchantRate" /> </wsdl:message>
<wsdl:message name="GetMerchantRateOut">
<wsdl:part name="parameters" element="tns:GetMerchantRateResult" /> </wsdl:message>
<wsdl:message name="GetCardRateIn">
<wsdl:part name="parameters" element="tns:GetCardRate" /> </wsdl:message>
<wsdl:message name="GetCardRateOut">
<wsdl:part name="parameters" element="tns:GetCardRateResult" /> </wsdl:message>
<!-- End of Dhs Server Messages -->
<!-- Port types --> <wsdl:portType name="DHS">
<wsdl:operation name="getMerchantRate">
<wsdl:documentation>Get Exchange Rate for merchant</wsdl:documentation> <wsdl:input message="tns:GetMerchantRateIn" />
<wsdl:output message="tns:GetMerchantRateOut" /> </wsdl:operation>
<wsdl:operation name="getCardRate">
<wsdl:documentation>Get Dynamic Currency conversion</wsdl:documentation> <wsdl:input message="tns:GetCardRateIn" />
<wsdl:output message="tns:GetCardRateOut" /> </wsdl:operation>
<!-- End of Dhs Server Operations --> </wsdl:portType>
<!-- WSDL bindings -->
<wsdl:binding name="DHS12" type="tns:DHS"> <wsdl:documentation>
<wsi:Claim conformsTo="http://ws-i.org/profiles/basic/1.1" /> </wsdl:documentation>
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="getMerchantRate">
<soap12:operation soapAction="http://www.fexcodcc.com/DCC20071126/ getMerchantRate" style="document" />
<wsdl:input>
<soap12:body use="literal" /> </wsdl:input>
<wsdl:output>
<soap12:body use="literal" /> </wsdl:output>
</wsdl:operation>
<wsdl:operation name="getCardRate">
<soap12:operation soapAction="http://www.fexcodcc.com/DCC20071126/ getCardRate" style="document" />
<wsdl:input>
<soap12:body use="literal" /> </wsdl:input>
<wsdl:output>
<soap12:body use="literal" /> </wsdl:output>
</wsdl:operation> </wsdl:binding>
<!-- WSDL service -->
<wsdl:service name="DHS">
<wsdl:documentation> DHS Server(Provides functionality to make DCC availability requests)</wsdl:documentation>
<wsdl:port name="DHS12" binding="tns:DHS12">
<soap12:address location="dhstest2.fexcodccapps.com/axis2/services/DHS" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
please help me figure out the error in any of the ways, whether wsimport or apache cxf. I will be really grateful.
in the schema declaration there is a space too much after the slashes: http:// www.fexcodcc.com/DCC20071126 instead of http://www.fexcodcc.com/DCC20071126.
try removing that space and it validates.
I am new to web services, I bought a book and started to learn from it, the WSDL is :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ttdev.com/ss" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SimpleService" targetNamespace="http://ttdev.com/ss">
<wsdl:types>
<xsd:schema targetNamespace="http://ttdev.com/ss">
<xsd:element name="concatRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="s1" type="xsd:string" />
<xsd:element name="s2" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="concatResponse" type="xsd:string">
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="concatRequest">
<wsdl:part element="tns:concatRequest" name="parameters"/>
</wsdl:message>
<wsdl:message name="concatResponse">
<wsdl:part element="tns:concatResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="SimpleService">
<wsdl:operation name="concat">
<wsdl:input message="tns:concatRequest"/>
<wsdl:output message="tns:concatResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SimpleServiceSOAP" type="tns:SimpleService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="concat">
<soap:operation soapAction="http://ttdev.com/ss/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SimpleService">
<wsdl:port binding="tns:SimpleServiceSOAP" name="p1">
<soap:address location="http://localhost:8080/ss/p1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I run the SimpleService_P1_Server, it s working, but when I run the client :
SimpleService_P1_Client I got this exeption :
Apr 8, 2012 9:51:47 AM com.ttdev.ss.SimpleService_Service <clinit>
INFO: Can not initialize the default wsdl from src/main/resources/SimpleService.wsdl
Exception in thread "main" javax.xml.ws.WebServiceException: Port {http://ttdev.com/ss}p1 not found.
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:328)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:319)
at javax.xml.ws.Service.getPort(Unknown Source)
at com.ttdev.ss.SimpleService_Service.getP1(SimpleService_Service.java:56)
at com.ttdev.ss.SimpleService_P1_Client.main(SimpleService_P1_Client.java:49)
Thanks, your help is appreciated.
I also faced similar issue some time back. You may want to use a prefix "file:" before "src/main/resources". Here is the resultant code:
WSDLToJava.main(new String[] { "-client", "-d", "src/main/java",
"file:src/main/resources/SimpleService.wsdl" });
I am writing a web service starting with writing the WSDL. I have been generating server-side skeleton code using wsimport and then writing my own implementing class. I'm running the web service on an Axis2 server. When using soapUI, the SOAP messages coming to and from the service look fine, but when using a web service client, I'm getting null in the client-side stubs. I've heard that this could be a namespace issue, but I see anything wrong. Here is my copy of the WSDL. Any help would be appreciated.
<?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://test.sa.lmco.com" 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:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://test.sa.lmco.com">
<!-- **************** -->
<!-- ** Types ** -->
<!-- **************** -->
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test.sa.lmco.com">
<xs:element name="sayHello">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="s" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sayHelloResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getTaxonomyNode">
<xs:complexType>
<xs:sequence>
<xs:element name="taxonomyId" minOccurs="1" maxOccurs="1" type="xs:int" />
<xs:element name="nodeId" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getTaxonomyNodeResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="resultNode" type="ns:TaxonomyNode" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getChildren">
<xs:complexType>
<xs:sequence>
<xs:element name="taxonomyId" minOccurs="1" maxOccurs="1" type="xs:int" />
<xs:element name="parentNodeId" minOccurs="1" maxOccurs="1" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getChildrenResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="childNodes" minOccurs="0" maxOccurs="unbounded" type="ns:TaxonomyNode" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="TaxonomyNode">
<xs:sequence>
<xs:element name="taxonomyId" type="xs:int" />
<xs:element name="nodeId" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="LCD">
<xs:sequence>
<xs:element name="language" type="xs:string" />
<xs:element name="content" type="xs:string" />
<xs:element name="description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<!-- ***************** -->
<!-- ** Messages ** -->
<!-- ***************** -->
<wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="ns:sayHello"/>
</wsdl:message>
<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="ns:sayHelloResponse"/>
</wsdl:message>
<wsdl:message name="getTaxonomyNodeRequest">
<wsdl:part name="parameters" element="ns:getTaxonomyNode" />
</wsdl:message>
<wsdl:message name="getTaxonomyNodeResponse">
<wsdl:part name="parameters" element="ns:getTaxonomyNodeResponse" />
</wsdl:message>
<wsdl:message name="getChildrenRequest">
<wsdl:part name="parameters" element="ns:getChildren" />
</wsdl:message>
<wsdl:message name="getChildrenResponse">
<wsdl:part name="parameters" element="ns:getChildrenResponse" />
</wsdl:message>
<!-- ******************* -->
<!-- ** PortTypes ** -->
<!-- ******************* -->
<wsdl:portType name="HelloWSPortType">
<wsdl:operation name="sayHello">
<wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello"/>
<wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse"/>
</wsdl:operation>
<wsdl:operation name="getTaxonomyNode">
<wsdl:input message="ns:getTaxonomyNodeRequest" wsaw:Action="urn:getTaxonomyNode" />
<wsdl:output message="ns:getTaxonomyNodeResponse" wsaw:Action="urn:getTaxonomyNodeResponse" />
</wsdl:operation>
<wsdl:operation name="getChildren">
<wsdl:input message="ns:getChildrenRequest" wsaw:Action="urn:getChildren" />
<wsdl:output message="ns:getChildrenResponse" wsaw:Action="urn:getChildrenResponse" />
</wsdl:operation>
</wsdl:portType>
<!-- ****************** -->
<!-- ** Bindings ** -->
<!-- ****************** -->
<wsdl:binding name="HelloWSServiceSoap11Binding" type="ns:HelloWSPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="urn:sayHello" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getTaxonomyNode">
<soap:operation soapAction="urn:getTaxonomyNode" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getChildren">
<soap:operation soapAction="urn:getChildren" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- **************** -->
<!-- ** Service ** -->
<!-- **************** -->
<wsdl:service name="HelloWS">
<wsdl:port name="HelloWSServiceHttpSoap11Endpoint" binding="ns:HelloWSServiceSoap11Binding">
<soap:address location="http://162.16.129.25:9090/axis2/services/HelloWS"/>
</wsdl:port>
</wsdl:service>
I was having the same problem with Soap web services, that is I am getting null response. I found the reason is I need to add appropriate Header fields in the request: Say for example - content-type, content-encoding, etc., depending on the service written. You better check with the one who has written the web services
This could be because of separate WSDL files.
If you specify WSDL separately in META-INF then AXIS2 passes arguments of the webservice as an OMElement.
I.e. if you have used other datatypes as arguments in service API and you have a WSDL in META-INF then while calling Service the parameters are OMElement not String / int or etc...