cannot access wsdl without bean name - java

I'm trying to access wsdl via http://localhost:8080/wsdlfirst/test.wsdl but not working when I do not set Wsdl11Definition bean name and tried to access http://localhost:8080/wsdlfirst?wsdl,
can someone point how to achieve this?
pom
`
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!-- cxf -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.5.2</version>
</dependency>
<!-- for javax.jws package. JAX-WS, plus SAAJ and Web Services Metadata -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>4.0.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>4.0.0-M3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlLocation>/courses.wsdl</wsdlLocation>
<wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
<sourceDestDir>${project.basedir}/target/generated-sources/</sourceDestDir>
<extension>true</extension>
<target>3.0</target>
<keep>true</keep>
<xnocompile>true</xnocompile>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
`
Here is WS config
#EnableWs
#Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
#Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setTransformWsdlLocations(true);
servlet.setApplicationContext(applicationContext);
return new ServletRegistrationBean<>(servlet, "/wsdlfirst/*");
}
#Bean ("test")
public Wsdl11Definition defaultWsdl11Definition() {
SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
wsdl11Definition.setWsdl(new ClassPathResource("/wsdl/courses.wsdl"));
return wsdl11Definition;
}
//
// #Bean (name="test")
// public Wsdl11Definition defaultWsdl11Definition(XsdSchema xsdSchema) throws Exception {
// DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
// wsdl11Definition.setPortTypeName("TutorialServicePort");
// wsdl11Definition.setSchema(xsdSchema);
// wsdl11Definition.setTargetNamespace("http://www.wstutorial.com/ws/TutorialService");
// wsdl11Definition.setLocationUri("/wsdlfirst");
// wsdl11Definition.setCreateSoap12Binding(true);
// wsdl11Definition.afterPropertiesSet();
// return wsdl11Definition;
// }
//
// #Bean
// public XsdSchema xsdSchema() {
// SimpleXsdSchema xsdSchema = new SimpleXsdSchema();
// xsdSchema.setXsd(new ClassPathResource("/wsdl/messages.xsd"));
// return xsdSchema;
// }
#Bean
SaajSoapMessageFactory messageFactory() {
SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
messageFactory.setSoapVersion(SoapVersion.SOAP_12);
return messageFactory;
}
}
WSDL
<types>
<xs:schema targetNamespace="http://www.wstutorial.com/ws/TutorialService">
<xs:complexType name="statusCode">
<xs:sequence>
<xs:element name="code" type="xs:long" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="TutorialType">
<xs:all>
<xs:element name="id" type="xs:long" />
<xs:element name="name" type="xs:string" />
<xs:element name="author" type="xs:string" />
</xs:all>
</xs:complexType>
...
<portType name="TutorialServicePortType">
<operation name="deleteTutorial">
<input message="tns:deleteTutorialRequestMsg" />
<output message="tns:deleteTutorialResponseMsg" />
<fault name="fault" message="tns:tutorialFault" />
</operation>
<operation name="updateTutorial">
<input message="tns:updateTutorialRequestMsg" />
<output message="tns:updateTutorialResponseMsg" />
<fault name="fault" message="tns:tutorialFault" />
</operation>
<operation name="getTutorials">
<input message="tns:getTutorialsRequestMsg" />
<output message="tns:getTutorialsResponseMsg" />
<fault name="fault" message="tns:tutorialFault" />
</operation>
</portType>
<binding name="tutorialServiceSOAPBinding" type="tns:TutorialServicePortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="deleteTutorial">
<soap:operation soapAction="deleteTutorial" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
<fault name="fault">
<soap:fault name="fault" use="literal" />
</fault>
</operation>
<operation name="updateTutorial">
<soap:operation soapAction="updateTutorial" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
<fault name="fault">
<soap:fault name="fault" use="literal" />
</fault>
</operation>
<operation name="getTutorials">
<soap:operation soapAction="getTutorials" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
<fault name="fault">
<soap:fault name="fault" use="literal" />
</fault>
</operation>
</binding>
<service name="TutorialService">
<port name="TutorialServicePort" binding="tns:tutorialServiceSOAPBinding">
<soap:address
location="http://localhost:8080/wsdlfirst/tutorialService" />
</port>
</service>
</definitions>
I have tried to change the Simple and Default Wsdl11Definition , but no luck.

Related

java web service calculator failing with postman cannot find dispatch method

so I have a simple calculator web service that im deploying locally using Jakarta.
its made up of three classes shown below.
Calculator
/**
* The annotation #WebService signals that this is the
* SEI (Service Endpoint Interface). #WebMethod signals
* that each method is a service operation.
*
* The #SOAPBinding annotation impacts the under-the-hood
* construction of the service contract, the WSDL
* (Web Services Definition Language) document. Style.RPC
* simplifies the contract and makes deployment easier.
*/
#WebService
#SOAPBinding(style = Style.RPC) // more on this later
public interface Calculator {
#WebMethod public double multiply(int i, int j);
#WebMethod public double minus(int i, int j);
#WebMethod public double plus(int i, int j);
#WebMethod double divide(int i, int j);
}
calculatorImpl
#WebService(endpointInterface = "calculator.Calculator")
public class CalculatorImpl implements Calculator {
#Override
public double multiply(int i , int j){
return i * j;
}
#Override
public double minus(int i , int j){
return i - j;
}
#Override
public double plus(int i , int j){
return i + j;
}
#Override
public double divide(int i, int j){
return i / j;
}
}
calculatorPublish
public class CalculatorPublish {
public static void main(String[] args) {
// TODO Auto-generated method stub
Endpoint.publish("http://127.0.0.1:8080/c", new CalculatorImpl());
}
}
so on to the problem. I can publish the webservice and it seems to work fine and generate the wsdl file shown below.
however when attempting to test this via postman I keep getting
Cannot find dispatch method for {}plus
this error happens for all the requests regardless of methods
in regards to postman:
im using post request
this is my url {{CalculatorImp|PortBaseUrl}}/c
I've removed charset from content type and only have xml
I've added SOAPAction with http://calculator/plus
I can't for the life of me work out why this isn't working
if any more info is needed please ask
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://calculator/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://calculator/" name="CalculatorImplService">
<types/>
<message name="multiply">
<part name="arg0" type="xsd:int"/>
<part name="arg1" type="xsd:int"/>
</message>
<message name="multiplyResponse">
<part name="return" type="xsd:double"/>
</message>
<message name="plus">
<part name="arg0" type="xsd:int"/>
<part name="arg1" type="xsd:int"/>
</message>
<message name="plusResponse">
<part name="return" type="xsd:double"/>
</message>
<message name="divide">
<part name="arg0" type="xsd:int"/>
<part name="arg1" type="xsd:int"/>
</message>
<message name="divideResponse">
<part name="return" type="xsd:double"/>
</message>
<message name="minus">
<part name="arg0" type="xsd:int"/>
<part name="arg1" type="xsd:int"/>
</message>
<message name="minusResponse">
<part name="return" type="xsd:double"/>
</message>
<portType name="Calculator">
<operation name="multiply" parameterOrder="arg0 arg1">
<input wsam:Action="http://calculator/Calculator/multiplyRequest" message="tns:multiply"/>
<output wsam:Action="http://calculator/Calculator/multiplyResponse" message="tns:multiplyResponse"/>
</operation>
<operation name="plus" parameterOrder="arg0 arg1">
<input wsam:Action="http://calculator/Calculator/plusRequest" message="tns:plus"/>
<output wsam:Action="http://calculator/Calculator/plusResponse" message="tns:plusResponse"/>
</operation>
<operation name="divide" parameterOrder="arg0 arg1">
<input wsam:Action="http://calculator/Calculator/divideRequest" message="tns:divide"/>
<output wsam:Action="http://calculator/Calculator/divideResponse" message="tns:divideResponse"/>
</operation>
<operation name="minus" parameterOrder="arg0 arg1">
<input wsam:Action="http://calculator/Calculator/minusRequest" message="tns:minus"/>
<output wsam:Action="http://calculator/Calculator/minusResponse" message="tns:minusResponse"/>
</operation>
</portType>
<binding name="CalculatorImplPortBinding" type="tns:Calculator">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="multiply">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://calculator/"/>
</input>
<output>
<soap:body use="literal" namespace="http://calculator/"/>
</output>
</operation>
<operation name="plus">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://calculator/"/>
</input>
<output>
<soap:body use="literal" namespace="http://calculator/"/>
</output>
</operation>
<operation name="divide">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://calculator/"/>
</input>
<output>
<soap:body use="literal" namespace="http://calculator/"/>
</output>
</operation>
<operation name="minus">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="http://calculator/"/>
</input>
<output>
<soap:body use="literal" namespace="http://calculator/"/>
</output>
</operation>
</binding>
<service name="CalculatorImplService">
<port name="CalculatorImplPort" binding="tns:CalculatorImplPortBinding">
<soap:address location="http://127.0.0.1:8080/c"/>
</port>
</service>
</definitions>

stub file in client class not recocgnised using soap

I followed this guide "http://wso2.com/library/1719/", I didn't modified nothig except in the part of java to wsdl where i setted the taget namespace as
http ://ws
and in schema target namespace
http ://ws
I used for this tutorial a service and a client. I generate correctly (the tomcat server doesn't give error in axis page) the.aar file and the wsdl from it.
Service:
`
import java.time.*;
import java.time.format.DateTimeFormatter;
public class ATMachine {
//program begin
public double deposita(double amount) {
Deposit.deposit = amount; //= read.nextDouble();
BalanceInquiry.balance = Deposit.deposit + BalanceInquiry.getBalance();
LocalDateTime date1= LocalDateTime.now();
String md= "deposit";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
String date2= date1.format(formatter);
BalanceInquiry.updateBalance(Deposit.deposit,BalanceInquiry.movement,md,date2);
return Deposit.deposit;
}
public double preleva(double amount) {
Withdraw.withdraw = amount;
LocalDateTime date = LocalDateTime.now();
String mw= "withdraw";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
String date3= date.format(formatter);
BalanceInquiry.updateBalance(Withdraw.withdraw,BalanceInquiry.movement,mw,date3);
int erwithdraw=BalanceInquiry.withdrawMoney(); // risposta di withdraw
return erwithdraw;
}
public String[] bilancio(){
double checkb=BalanceInquiry.getBalance();
String[] rbilancio= new String[12];
rbilancio[0]= Double.toHexString(checkb);
for(int i1=1;i1<=rbilancio.length;i1++){
for(int i=0;i<= BalanceInquiry.movement.length-1; i++){
if(BalanceInquiry.movement[i]==null){
rbilancio[i1]="";
}
else{rbilancio[i1]=BalanceInquiry.movement[i];
}
}
}
return rbilancio;
}
}
`
ATMClient
`
package ws;
import java.util.Scanner;
import java.io.*;
import java.util.Properties;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.PolicyInclude;
import org.apache.neethi.Policy;
import org.apache.rampart.policy.model.CryptoConfig;
import org.apache.rampart.policy.model.RampartConfig;
import org.apache.axiom.om.OMElement;
public class ATMClient {
public static void main(String[] args)
{
Scanner read = new Scanner(System.in);
double amount=0;
int select = 0;
int choice = 0;
//To be able to load the client configuration from axis2.xml
//ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("axis-repo",null);
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("axis-repo", "axis-repo\\conf\\axis2.xml");
ATMachineStub stub = new ATMachineStub(ctx,"http://localhost:8888/axis2/services/ATMachine");
ServiceClient sc = stub._getServiceClient();
sc.engageModule("rampart");
System.out.println("====================================================");
System.out.println("\tWelcome to this simple ATM machine");
System.out.println("====================================================");
System.out.println();
do
{try
{
do {
System.out.println("\tPlease select ATM Transactions");
System.out.println("\tPress [1] Deposit");
System.out.println("\tPress [2] Withdraw");
System.out.println("\tPress [3] Balance Inquiry");
System.out.println("\tPress [4] Exit");
System.out.print("\n\tWhat would you like to do? ");
select = read.nextInt();
if(select>4)
{
System.out.println("\n\tPlease select correct transaction.");
}
else
{
switch (select)
{
case 1:
amount=0;
System.out.print("\n\tEnter the amount of money to deposit: ");
amount= read.nextDouble();
double result= stub.deposita(amount);
System.out.println("\tYou deposited the amount of " + amount);
break;
case 2:
amount=0;
System.out.print("\n\tTo withdraw, make sure that you have sufficient balance in your account.");
System.out.println();
System.out.print("\tEnter amount of money to withdraw: ");
amount= read.nextDouble();
double erpreleva=stub.preleva(amount);
if(erpreleva==1)
{
System.out.println("\tYour current balance is zero.");
System.out.println("\tYou cannot withdraw!");
System.out.println("\tYou need to deposit money first.");
}
else if(erpreleva==2)
{
System.out.println("\tThe amount you withdraw is greater than to your balance");
System.out.println("\tPlease check the amount you entered.");
}
else
{
System.out.println("\n\tYou withdraw the amount of Php " + amount);
}
break;
case 3:
String[] bilanciores= new String[12];
bilanciores=stub.bilancio();
System.out.println("\tYour current balance is:" + bilanciores[0]);
System.out.println();
System.out.println("\tThe last 10 operation are:\n ");
for(int i=1;i<bilanciores.length;i++){
System.out.println("\t"+ bilanciores[i] +"\n");
}
break;
default:
System.out.print("\n\tTransaction exited.");
break;
}
}
}while(select>4);
do {
try
{
System.out.println("\n\tWould you like to try another transaction?");
System.out.println("\n\tPress [1] Yes \n\tPress [2] No");
System.out.print("\tEnter choice: ");
choice = read.nextInt();
if(choice>2)
{
System.out.print("\n\tPlease select correct choice.");
}
}
catch(Exception e)
{
System.out.println("\tError Input! Please enter a number only.");
read = new Scanner(System.in);
System.out.println("\tEnter yout choice:");
choice = read.nextInt();
}
} while(choice>2);
}
catch(Exception e)
{
System.out.println("\tError Input! Please enter a number only.");
read = new Scanner(System.in);
System.out.println("\tEnter yout choice:");
select = read.nextInt();
}
}while(choice<=1);
System.out.println("\n\tThank you for using this simple ATM Machine.");
}
}
`
The classes BalanceInquiry, Deposit, Withdraw have get and response methods and works.
All the declared libraries are added to the project.
But in ATMClient Eclipse says
ATMachineStub cannot be resolved to a type
I also tried to create an interface with the wizard using instead that ws and ws, ws and ws/xsd but cause error on the methods bilancio(), deposita(), and preleva() requiring to modify the parameters in the ATMchineStub file froma deposita(Deposita) to deposita(double), (the same for the other methods).
I post also the xml file of the wsdl :
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://ws.apache.org/axis2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://ws.apache.org/axis2">
<wsdl:documentation>ATMachine</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2">
<xs:element name="deposita">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="amount" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="depositaResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="preleva">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="amount" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="prelevaResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="bilancioResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="bilancioRequest"/>
<wsdl:message name="bilancioResponse">
<wsdl:part name="parameters" element="ns:bilancioResponse"/>
</wsdl:message>
<wsdl:message name="prelevaRequest">
<wsdl:part name="parameters" element="ns:preleva"/>
</wsdl:message>
<wsdl:message name="prelevaResponse">
<wsdl:part name="parameters" element="ns:prelevaResponse"/>
</wsdl:message>
<wsdl:message name="depositaRequest">
<wsdl:part name="parameters" element="ns:deposita"/>
</wsdl:message>
<wsdl:message name="depositaResponse">
<wsdl:part name="parameters" element="ns:depositaResponse"/>
</wsdl:message>
<wsdl:portType name="ATMachinePortType">
<wsdl:operation name="bilancio">
<wsdl:input message="ns:bilancioRequest" wsaw:Action="urn:bilancio"/>
<wsdl:output message="ns:bilancioResponse" wsaw:Action="urn:bilancioResponse"/>
</wsdl:operation>
<wsdl:operation name="preleva">
<wsdl:input message="ns:prelevaRequest" wsaw:Action="urn:preleva"/>
<wsdl:output message="ns:prelevaResponse" wsaw:Action="urn:prelevaResponse"/>
</wsdl:operation>
<wsdl:operation name="deposita">
<wsdl:input message="ns:depositaRequest" wsaw:Action="urn:deposita"/>
<wsdl:output message="ns:depositaResponse" wsaw:Action="urn:depositaResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ATMachineSoap11Binding" type="ns:ATMachinePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="bilancio">
<soap:operation soapAction="urn:bilancio" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="preleva">
<soap:operation soapAction="urn:preleva" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="deposita">
<soap:operation soapAction="urn:deposita" 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="ATMachineSoap12Binding" type="ns:ATMachinePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="bilancio">
<soap12:operation soapAction="urn:bilancio" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="preleva">
<soap12:operation soapAction="urn:preleva" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="deposita">
<soap12:operation soapAction="urn:deposita" 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="ATMachineHttpBinding" type="ns:ATMachinePortType">
<http:binding verb="POST"/>
<wsdl:operation name="bilancio">
<http:operation location="ATMachine/bilancio"/>
<wsdl:input>
<mime:content type="text/xml" part="bilancio"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="bilancio"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="preleva">
<http:operation location="ATMachine/preleva"/>
<wsdl:input>
<mime:content type="text/xml" part="preleva"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="preleva"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="deposita">
<http:operation location="ATMachine/deposita"/>
<wsdl:input>
<mime:content type="text/xml" part="deposita"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="deposita"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ATMachine">
<wsdl:port name="ATMachineHttpSoap11Endpoint" binding="ns:ATMachineSoap11Binding">
<soap:address location="http://localhost:8080/axis2/services/ATMachine.ATMachineHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="ATMachineHttpSoap12Endpoint" binding="ns:ATMachineSoap12Binding">
<soap12:address location="http://localhost:8080/axis2/services/ATMachine.ATMachineHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="ATMachineHttpEndpoint" binding="ns:ATMachineHttpBinding">
<http:address location="http://localhost:8080/axis2/services/ATMachine.ATMachineHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Can somebody suggest me how to solve it ?
I solved it using WSS4J by terminal. Instead of the eclipse service it has solved.

PHP SoapClient calling Java Web-Service

this is first day I'm looking into Web-Services and I'm already stuck.
I got a simple Java-Code:
#WebService
public class ProductCatalog {
public void getCategory(String category) {
System.out.println(category);
}
}
Then I got the PHP-Code to call this function:
try{
$client = new SoapClient("link/to/wsdl");
$category = "music";
$client->getCategory($category);
}
catch(SoapFault $exception){
echo $exception->getMessage();
}
The console output is null.
The following
public void getProducts() {
System.out.println("Works");
}
with the same PHP-Code works, so the method call itself is working.
As said, it's my first day, so please don't go too hard on me!
edit: here is the WSDL
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://main/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://main/" name="ProductCatalogService">
<types>
<xsd:schema>
<xsd:import namespace="http://main/" schemaLocation="http://127.0.0.1:8080/Testmart/ProductCatalogService?xsd=1"/>
</xsd:schema>
</types>
<message name="getProducts">
<part name="parameters" element="tns:getProducts"/>
</message>
<message name="getProductsResponse">
<part name="parameters" element="tns:getProductsResponse"/>
</message>
<portType name="ProductCatalog">
<operation name="getProducts">
<input wsam:Action="http://main/ProductCatalog/getProductsRequest" message="tns:getProducts"/>
<output wsam:Action="http://main/ProductCatalog/getProductsResponse" message="tns:getProductsResponse"/>
</operation>
</portType>
<binding name="ProductCatalogPortBinding" type="tns:ProductCatalog">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getProducts">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ProductCatalogService">
<port name="ProductCatalogPort" binding="tns:ProductCatalogPortBinding">
<soap:address location="http://127.0.0.1:8080/Testmart/ProductCatalogService"/>
</port>
</service>
</definitions>
I encountered the same problem.
Call the function like this:
$response = $client->getCategory(array("arg0"=> $category));
I don't know why, but the first parameters of the function is arg0,
if it's not working, check the webservice with programs that can connect to webservice, and than you'll get the name of params.

Android ksoap2 web service gets me the XML description of WSDL?

I'm using ksoap2 to call a simple method but at response I get the XML description on web service? This method simply get username and password and returns user balance.
My Code:
public class FaraSMSActivity extends Activity {
private final String NAMESPACE = "http://farasms.com/SMSSYSTEM";
private final String URL = "http://farasms.com/webservice/v2.02.php?wsdl";
private final String SOAP_ACTION = "http://farasms.com/SMSSYSTEM#WSGETBalance__";
private final String METHOD_NAME = "WSGETBalance__";
private String TAG = "PGGURU";
private static String res;
Button b;
TextView tv;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.tv_result);
b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
AsyncCallWS task = new AsyncCallWS();
task.execute();
}
});
}
public void getBalance() {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo usernamePI = new PropertyInfo();
usernamePI.setName("username");
usernamePI.setValue("faramobile");
usernamePI.setType(String.class);
request.addProperty(usernamePI);
PropertyInfo PasswordPI = new PropertyInfo();
PasswordPI.setName("password");
PasswordPI.setValue("09142168375");
PasswordPI.setType(String.class);
request.addProperty(PasswordPI);
//Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
//Set output SOAP object
envelope.setOutputSoapObject(request);
//Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
//Get the response
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
res = response.toString();
} catch (Exception e) {
Log.e("1111", e.getMessage());
e.printStackTrace();
}
Log.e("2222", androidHttpTransport.responseDump);
}
private class AsyncCallWS extends AsyncTask<String, Void, Void> {
#Override
protected Void doInBackground(String... params) {
getBalance();
return null;
}
#Override
protected void onPostExecute(Void result) {
tv.setText(res);
}
#Override
protected void onPreExecute() {
tv.setText("Connecting...");
}
#Override
protected void onProgressUpdate(Void... values) {
}
}
}
using this line I can log the result :
Log.e("2222", androidHttpTransport.responseDump);
It show exactly the thing when I explore "farasms.com/webservice/v2.02.php?wsdl" using web browser!!!!
This is the result :
<?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://farasms.com/SMSSYSTEM" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://farasms.com/SMSSYSTEM">
<types>
<xsd:schema targetNamespace="http://farasms.com/SMSSYSTEM">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<xsd:complexType name="authentication">
<xsd:all>
<xsd:element name="username" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="returnCode">
<xsd:all>
<xsd:element name="msgid" type="xsd:string"/>
<xsd:element name="status" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="message">
<xsd:all>
<xsd:element name="fromNum" type="xsd:string"/>
<xsd:element name="toNum" type="xsd:string"/>
<xsd:element name="msg" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="fullmessage">
<xsd:all>
<xsd:element name="fromNum" type="xsd:string"/>
<xsd:element name="toNum" type="xsd:string"/>
<xsd:element name="msg" type="xsd:string"/>
<xsd:element name="date" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="returnCodes">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:returnCode[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="msgids">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="messages">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:message[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="fullmessages">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:fullmessage[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="WSGETBalanceRequest">
<part name="authentication" type="tns:authentication"/>
<part name="username" type="xsd:string"/>
</message>
<message name="WSGETBalanceResponse">
<part name="result" type="xsd:string"/>
</message>
<message name="WSGETBalance__Request">
<part name="username" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="WSGETBalance__Response">
<part name="result" type="xsd:string"/>
</message>
<message name="WSdoSendSMS1Request">
<part name="authentication" type="tns:authentication"/>
<part name="message" type="tns:message"/>
</message>
<message name="WSdoSendSMS1Response">
<part name="result" type="xsd:string"/>
</message>
<message name="WSdoSendSMS3Request">
<part name="username" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="from" type="xsd:string"/>
<part name="to" type="xsd:string"/>
<part name="msg" type="xsd:string"/>
</message>
<message name="WSdoSendSMS3Response">
<part name="result" type="xsd:string"/>
</message>
<message name="WSdoSendSMS4Request">
<part name="authentication" type="tns:authentication"/>
<part name="message" type="tns:fullmessage"/>
</message>
<message name="WSdoSendSMS4Response">
<part name="result" type="xsd:string"/>
</message>
<message name="WSgetDeliveryRequest">
<part name="authentication" type="tns:authentication"/>
<part name="msgids" type="tns:msgids"/>
</message>
<message name="WSgetDeliveryResponse">
<part name="result" type="tns:returnCodes"/>
</message>
<message name="WSchangePasswordRequest">
<part name="authentication" type="tns:authentication"/>
<part name="newPassword" type="xsd:string"/>
</message>
<message name="WSchangePasswordResponse">
<part name="result" type="xsd:string"/>
</message>
<message name="WSgetMessagesRequest">
<part name="authentication" type="tns:authentication"/>
<part name="numRows" type="xsd:int"/>
</message>
<message name="WSgetMessagesResponse">
<part name="result" type="tns:messages"/>
</message>
<message name="WSgetNewMessagesRequest">
<part name="authentication" type="tns:authentication"/>
</message>
<message name="WSgetNewMessagesResponse">
<part name="result" type="tns:messages"/>
</message>
<portType name="SMSSYSTEMPortType">
<operation name="WSGETBalance">
<documentation>WSGETBalance</documentation>
<input message="tns:WSGETBalanceRequest"/>
<output message="tns:WSGETBalanceResponse"/>
</operation>
<operation name="WSGETBalance__">
<documentation>WSGETBalance__</documentation>
<input message="tns:WSGETBalance__Request"/>
<output message="tns:WSGETBalance__Response"/>
</operation>
<operation name="WSdoSendSMS1">
<documentation>WSdoSendSMS1</documentation>
<input message="tns:WSdoSendSMS1Request"/>
<output message="tns:WSdoSendSMS1Response"/>
</operation>
<operation name="WSdoSendSMS3">
<documentation>WSdoSendSMS3</documentation>
<input message="tns:WSdoSendSMS3Request"/>
<output message="tns:WSdoSendSMS3Response"/>
</operation>
<operation name="WSdoSendSMS4">
<documentation>WSdoSendSMS4</documentation>
<input message="tns:WSdoSendSMS4Request"/>
<output message="tns:WSdoSendSMS4Response"/>
</operation>
<operation name="WSgetDelivery">
<documentation>WSgetDelivery</documentation>
<input message="tns:WSgetDeliveryRequest"/>
<output message="tns:WSgetDeliveryResponse"/>
</operation>
<operation name="WSchangePassword">
<documentation>WSchangePassword</documentation>
<input message="tns:WSchangePasswordRequest"/>
<output message="tns:WSchangePasswordResponse"/>
</operation>
<operation name="WSgetMessages">
<documentation>WSgetMessages</documentation>
<input message="tns:WSgetMessagesRequest"/>
<output message="tns:WSgetMessagesResponse"/>
</operation>
<operation name="WSgetNewMessages">
<documentation>WSgetNewMessages</documentation>
<input message="tns:WSgetNewMessagesRequest"/>
<output message="tns:WSgetNewMessagesResponse"/>
</operation>
</portType>
<binding name="SMSSYSTEMBinding" type="tns:SMSSYSTEMPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="WSGETBalance">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSGETBalance" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSGETBalance__">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSGETBalance__" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSdoSendSMS1">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSdoSendSMS1" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSdoSendSMS3">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSdoSendSMS3" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSdoSendSMS4">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSdoSendSMS4" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSgetDelivery">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSgetDelivery" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSchangePassword">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSchangePassword" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSgetMessages">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSgetMessages" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="WSgetNewMessages">
<soap:operation soapAction="http://farasms.com/SMSSYSTEM#WSgetNewMessages" style="rpc"/>
<input>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="http://farasms.com/SMSSYSTEM" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="SMSSYSTEM">
<port name="SMSSYSTEMPort" binding="tns:SMSSYSTEMBinding">
<soap:address location="http://farasms.com/webservice/v2.02.php"/>
</port>
</service>
</definitions>
What wrong am i doing ?
OK, after searching a lot, I found the reason. The correct URL is this :
private final String URL = "http://farasms.com/webservice/v2.02.php";
I pointed the URL to WSDL itself not the webservice!

Axis WSDL2Java generation issue

I've wrote some simple service that consists of several files (wsdl, xsd).
In xsd file I've got following definition:
<xs:complexType name="ServerMessage">
<xs:sequence>
<xs:element name="type" type="xs:int"/>
<xs:element name="info" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="ServerMessage" type="tns:ServerMessage"/>
Then this element is referenced in wsdl file like this
<wsdl:message name="createItemFault">
<wsdl:part name="createItemFault" element="tns:ServerMessage"/>
</wsdl:message>
<wsdl:portType name="Service">
<wsdl:operation name="createItem">
<wsdl:input message="tns:createItemRequest"/>
<wsdl:output message="tns:createItemResponse"/>
<wsdl:fault name="Fault" message="tns:createItemFault"/>
</wsdl:operation>
And at last
<wsdl:binding name="ServiceBinding" type="intf:Service">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="createItem">
<soap:operation soapAction="http://test.com/createItem"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="Fault">
<soap:fault name="Fault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
After launching WSDL2Java I receive the following code
public interface ServerMessage extends org.apache.xmlbeans.XmlObject
{
How come ServerMessage becomes defined like this? When I've used WSDL2Java provided by Axis1 final definition in java file was like this
public class ServerMessage extends org.apache.axis.AxisFault implements java.io.Serializable
And after Axis2 generation resulting "item" is drastically differs, it's not even throwable. What am I doing wrong?
From that WSDL you should get a CreateItemFault (due to the wsdl:message name) that looks something like:
public class CreateItemFault extends java.lang.Exception {
private org.example.www.service.ServerMessageDocument faultMessage;
...
}
That ServerMessageDocument probably looks like:
public interface ServerMessageDocument extends org.apache.xmlbeans.XmlObject {
...
org.example.www.service.ServerMessage getServerMessage();
void setServerMessage(org.example.www.service.ServerMessage serverMessage);
org.example.www.service.ServerMessage addNewServerMessage();
...
}
And here's where we get to your ServerMessage:
public interface ServerMessage extends org.apache.xmlbeans.XmlObject {
...
}
The method signature should throw a CreateItemFault, though.

Categories