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!
Related
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>
Faced a problem. How to put input data into a soap request, which is generated by means of SOARequestCreator (com.predic8.wsdl library).
My method:
#SneakyThrows
public String parseTEst(MultipartFile file) {
WSDLParser parser = new WSDLParser();
Definitions defs = parser.parse(file.getInputStream());
StringWriter writer = new StringWriter();
HashMap<String, String> formParams = new HashMap<String, String>();
formParams.put("xpath:/Add/intA", "1");
formParams.put("intB", "2");
SOARequestCreator creator = new SOARequestCreator(defs, new RequestTemplateCreator(), new MarkupBuilder(writer));
creator.setFormParams(formParams);
creator.createRequest("CalculatorSoap", "Add", "CalculatorSoap");
System.out.println(writer);
return writer.toString();
}
This method returtn:
<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
<s11:Body>
<ns1:Add xmlns:ns1='http://tempuri.org/'>
<ns1:intA>?999?</ns1:intA>
<ns1:intB>?999?</ns1:intB>
</ns1:Add>
</s11:Body>
</s11:Envelope>
How to replace "intA" and "intB"?
I think this should most likely be done here:
HashMap<String, String> formParams = new HashMap<String, String>();
formParams.put("xpath:/Add/intA", "1");
formParams.put("intB", "2");
SOARequestCreator creator = new SOARequestCreator(defs, new RequestTemplateCreator(), new MarkupBuilder(writer));
creator.setFormParams(formParams);
Because so in the documentation on tis site(http://www.membrane-soa.org/soa-model-doc/1.4/java-api/create-soap-request.htm):
HashMap<String, String> formParams = new HashMap<String, String>();
formParams.put("xpath:/create/article/name", "foo");
formParams.put("xpath:/create/article/description", "bar");
formParams.put("xpath:/create/article/price/amount", "00.00");
formParams.put("xpath:/create/article/price/currency", "USD");
formParams.put("xpath:/create/article/id", "1");
//SOARequestCreator constructor: SOARequestCreator(Definitions, Creator, MarkupBuilder)
SOARequestCreator creator = new SOARequestCreator(wsdl, new RequestCreator(), new MarkupBuilder(writer));
creator.setFormParams(formParams);
My wsdl file:
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://tempuri.org/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="Add">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="intA" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="intB" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AddResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AddResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="Subtract">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="intA" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="intB" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SubtractResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="SubtractResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="Multiply">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="intA" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="intB" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="MultiplyResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="MultiplyResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="Divide">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="intA" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="intB" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DivideResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="DivideResult" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="AddSoapIn">
<wsdl:part name="parameters" element="tns:Add"/>
</wsdl:message>
<wsdl:message name="AddSoapOut">
<wsdl:part name="parameters" element="tns:AddResponse"/>
</wsdl:message>
<wsdl:message name="SubtractSoapIn">
<wsdl:part name="parameters" element="tns:Subtract"/>
</wsdl:message>
<wsdl:message name="SubtractSoapOut">
<wsdl:part name="parameters" element="tns:SubtractResponse"/>
</wsdl:message>
<wsdl:message name="MultiplySoapIn">
<wsdl:part name="parameters" element="tns:Multiply"/>
</wsdl:message>
<wsdl:message name="MultiplySoapOut">
<wsdl:part name="parameters" element="tns:MultiplyResponse"/>
</wsdl:message>
<wsdl:message name="DivideSoapIn">
<wsdl:part name="parameters" element="tns:Divide"/>
</wsdl:message>
<wsdl:message name="DivideSoapOut">
<wsdl:part name="parameters" element="tns:DivideResponse"/>
</wsdl:message>
<wsdl:portType name="CalculatorSoap">
<wsdl:operation name="Add">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Adds two integers. This is a test
WebService. ©DNE Online
</wsdl:documentation>
<wsdl:input message="tns:AddSoapIn"/>
<wsdl:output message="tns:AddSoapOut"/>
</wsdl:operation>
<wsdl:operation name="Subtract">
<wsdl:input message="tns:SubtractSoapIn"/>
<wsdl:output message="tns:SubtractSoapOut"/>
</wsdl:operation>
<wsdl:operation name="Multiply">
<wsdl:input message="tns:MultiplySoapIn"/>
<wsdl:output message="tns:MultiplySoapOut"/>
</wsdl:operation>
<wsdl:operation name="Divide">
<wsdl:input message="tns:DivideSoapIn"/>
<wsdl:output message="tns:DivideSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorSoap" type="tns:CalculatorSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Add">
<soap:operation soapAction="http://tempuri.org/Add" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Subtract">
<soap:operation soapAction="http://tempuri.org/Subtract" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Multiply">
<soap:operation soapAction="http://tempuri.org/Multiply" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Divide">
<soap:operation soapAction="http://tempuri.org/Divide" 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="CalculatorSoap12" type="tns:CalculatorSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Add">
<soap12:operation soapAction="http://tempuri.org/Add" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Subtract">
<soap12:operation soapAction="http://tempuri.org/Subtract" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Multiply">
<soap12:operation soapAction="http://tempuri.org/Multiply" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Divide">
<soap12:operation soapAction="http://tempuri.org/Divide" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Calculator">
<wsdl:port name="CalculatorSoap" binding="tns:CalculatorSoap">
<soap:address location="http://www.dneonline.com/calculator.asmx"/>
</wsdl:port>
<wsdl:port name="CalculatorSoap12" binding="tns:CalculatorSoap12">
<soap12:address location="http://www.dneonline.com/calculator.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Help me pls!
Thanks!
Most likely because the xpath expression is different than the first? The second one doesnt have the xpath: prefix ? That still doesnt explain why the first one doesnt work.
formParams.put("xpath:/Add/intA", "1");
formParams.put("intB", "2");
I faced the same problem and took me quite a while to figure it out. The params values are correct, but the creator is not the one needed.
SOARequestCreator creator = new SOARequestCreator(defs, new RequestTemplateCreator(), new MarkupBuilder(writer));
Will generate the payload without any values from the params because RequestTemplateCreator is used. If instead RequestCreator is used, values will be filled.
i have created soap webservice,in this web service i have add(int a, int b) which takes parameter integer type.
Now my question is how to consume this method by passing these parameter using java? how to make soap client using java ?
WSDL
<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://service.ss.com" xmlns:intf="http://service.ss.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://service.ss.com">
<!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)
-->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://service.ss.com">
<element name="add">
<complexType>
<sequence>
<element name="a" type="xsd:int"/>
<element name="b" type="xsd:int"/>
</sequence>
</complexType>
</element>
<element name="addResponse">
<complexType>
<sequence>
<element name="addReturn" type="xsd:int"/>
</sequence>
</complexType>
</element>
<element name="insert">
<complexType/>
</element>
<element name="insertResponse">
<complexType>
<sequence>
<element name="insertReturn" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="getDate">
<complexType/>
</element>
<element name="getDateResponse">
<complexType>
<sequence>
<element name="getDateReturn" type="xsd:dateTime"/>
</sequence>
</complexType>
</element>
<element name="findAll">
<complexType/>
</element>
<element name="findAllResponse">
<complexType>
<sequence>
<element name="findAllReturn" type="xsd:string"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="insertRequest">
<wsdl:part element="impl:insert" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part element="impl:addResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="findAllRequest">
<wsdl:part element="impl:findAll" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="addRequest">
<wsdl:part element="impl:add" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="getDateResponse">
<wsdl:part element="impl:getDateResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="insertResponse">
<wsdl:part element="impl:insertResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="getDateRequest">
<wsdl:part element="impl:getDate" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="findAllResponse">
<wsdl:part element="impl:findAllResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="TestService">
<wsdl:operation name="add">
<wsdl:input message="impl:addRequest" name="addRequest"></wsdl:input>
<wsdl:output message="impl:addResponse" name="addResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="insert">
<wsdl:input message="impl:insertRequest" name="insertRequest"></wsdl:input>
<wsdl:output message="impl:insertResponse" name="insertResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="getDate">
<wsdl:input message="impl:getDateRequest" name="getDateRequest"></wsdl:input>
<wsdl:output message="impl:getDateResponse" name="getDateResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="findAll">
<wsdl:input message="impl:findAllRequest" name="findAllRequest"></wsdl:input>
<wsdl:output message="impl:findAllResponse" name="findAllResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="TestServiceSoapBinding" type="impl:TestService">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="add">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="addRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="addResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="insert">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="insertRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="insertResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getDate">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getDateRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getDateResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="findAll">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="findAllRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="findAllResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TestServiceService">
<wsdl:port binding="impl:TestServiceSoapBinding" name="TestService">
<wsdlsoap:address location="http://localhost:8080/SoapService/services/TestService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Code
This code is working good, but i don't know how to pass the parameters.
String requestContent= "";
WsdlProject project = new WsdlProject();
WsdlInterface[] wsdls = WsdlImporter.importWsdl(project, "http://host.ubnsoft.com:8080/SoapService/services/TestService?wsdl");
WsdlInterface wsdl = wsdls[0];
List<Operation> operations = wsdl.getOperationList();
for (Operation operation : operations) {
WsdlOperation wsdlOperation = (WsdlOperation) operation;
// create a new empty request for that operation
WsdlRequest request = wsdlOperation.addNewRequest("My request");
request.setTimeout("2000");
requestContent = wsdlOperation.createRequest(true);
request.setRequestContent(requestContent);
System.out.println("REQUEST: " + requestContent);
// submit the request
try {
WsdlSubmit submit = (WsdlSubmit) request.submit(new WsdlSubmitContext(request), false);
Status status = submit.getStatus(); //FINISHED OR ERROR
System.out.println("STATUS: " + status);
Response response = submit.getResponse();
System.out.println("RESPONSE: " + response.getContentAsString());
} catch (SubmitException e) {
e.printStackTrace();
}
}
How to send request with parameter and getting the response in soap using java?
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.
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.