AND THIS VERSION WORKS!
this is my very simple Web service ( HelloWorld ):
ps:It's C# not java
Using java Syntax Highlighting
- namespace WebService1
- {
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- [ToolboxItem(false)]
- public class Service1 : System.Web.Services.WebService
- {
- [WebMethod]
- public string HelloWorld()
- {
- return "Hello World";
- }
- }
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
And its WSDL
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 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/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
- <s:element name="HelloWorld">
- <s:complexType />
- </s:element>
- <s:element name="HelloWorldResponse">
- <s:complexType>
- <s:sequence>
- <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" />
- </s:sequence>
- </s:complexType>
- </s:element>
- </s:schema>
- </wsdl:types>
- <wsdl:message name="HelloWorldSoapIn">
- <wsdl:part name="parameters" element="tns:HelloWorld" />
- </wsdl:message>
- <wsdl:message name="HelloWorldSoapOut">
- <wsdl:part name="parameters" element="tns:HelloWorldResponse" />
- </wsdl:message>
- <wsdl:portType name="Service1Soap">
- <wsdl:operation name="HelloWorld">
- <wsdl:input message="tns:HelloWorldSoapIn" />
- <wsdl:output message="tns:HelloWorldSoapOut" />
- </wsdl:operation>
- </wsdl:portType>
- <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
- <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="HelloWorld">
- <soap:operation soapAction="http://tempuri.org/HelloWorld" 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="Service1Soap12" type="tns:Service1Soap">
- <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="HelloWorld">
- <soap12:operation soapAction="http://tempuri.org/HelloWorld" 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="Service1">
- <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
- <soap:address location="http://localhost/WebService1/Service1.asmx" />
- </wsdl:port>
- <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
- <soap12:address location="http://localhost/WebService1/Service1.asmx" />
- </wsdl:port>
- </wsdl:service>
- </wsdl:definitions>
Parsed in 0.012 seconds, using GeSHi 1.0.8.4
Im tring to call it with this android code (192.168.1.81 is my ip) :
Using java Syntax Highlighting
- public class WSAndroid extends Activity {
- private Button okButton;
- private TextView result;
- private Object resultRequestSoap = null;
- private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
- private static final String METHOD_NAME = "HelloWorld";
- private static final String NAMESPACE = "http://tempuri.org/";
- private static final String URL = "http://192.168.1.81/Service1/Service1.asmx?wsdl";
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.main);
- result = (TextView) findViewById(R.id.result);
- okButton = (Button) findViewById(R.id.invio);
- okButton.setOnClickListener(new Button.OnClickListener() {
- public void onClick(View v) {
- try {
- callWebService();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (XmlPullParserException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- });
- }
- public void callWebService() throws IOException, XmlPullParserException{
- SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
- envelope.dotNet = true;
- envelope.setOutputSoapObject(request);
- HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
- try {
- androidHttpTransport.call(SOAP_ACTION, envelope);
- resultRequestSoap = envelope.getResponse();
- //Parse Response
- SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;
- //Return a String for view
- result.setText(resultsRequestSOAP.getProperty(0).toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
You can use this as simple base tutorial to access a web service using ksoap2



