Hi again,
We just need to make a call to a .net webservice running at another machine,
We have the wsdl (Attached: NewFile.asmx.wsdl)
We create the wdsl using the manual:
java org.apache.axis.wsdl.WSDL2Java NewFile.asmx.wsdl
The generated classes are:
Prueba1.java
Prueba1Locator.java
Prueba1Soap12Stub.java
Prueba1Soap.java
Prueba1SoapStub.java
Our client imports the "longhorn.Prueba1Locator"
// CODE //
public final String prueba(){
String response = null;
boolean ok = true;
try {
Integer num1 = new Integer(2);
Integer num2 = new Integer(5);
String method = "Add";
String url = "http://longhorn/prueba1/NewFile.asmx";
org.apache.axis.client.Service service = new
Prueba1Locator();
org.apache.axis.client.Call call =
(org.apache.axis.client.Call) service.createCall();
QName qnamer = service.getServiceName();
call.setTargetEndpointAddress( new java.net.URL(url) );
call.setOperationName(method);
call.addParameter( "a", XMLType.XSD_INT, ParameterMode.IN
);
call.addParameter( "b", XMLType.XSD_INT, ParameterMode.IN );
call.setReturnType(XMLType.XSD_INT);
response = ((Integer)call.invoke(new Object[] { num1, num2
})).toString();
}
catch(Exception e) {
return "NOK";
}finally{
}
return response;
} // CODE //
The error returned is:
Server did no recognize the value of HTTP Header SOAPAction: .
Where is the problem or what are we doing wrong?
Thanks on advance again
Raúl.
PD: Doing what Felipe Palma suggest seems to create a webservice isn't it?
We neet just the client.
-----Mensaje original-----
De: Felipe Palma Dias [mailto:[EMAIL PROTECTED]
Enviado el: jueves, 15 de septiembre de 2005 20:35
Para: [email protected]
Asunto: Re: WSDL2Java Newbie Question
1- create a Java interface (MyJavaInterface.java)
2- create the WSDL from java interface.
java org.apache.axis.wsdl.WSDL2Java -o . -s -S true
-Nurn:MyJavaInterface com.sample MyJavaInterface.wsdl
3- creates the stub and skeleton classes:
java org.apache.axis.wsdl.Java2WSDL -o
MyJavaInterface.wsdl -l
http://localhost:8080/axis/services/MyJavaInterface -n
urn:MyJavaInterface com.sample.MyJavaInterface
4- deploy the service:
java -cp $CP org.apache.axis.client.AdminClient
deploy.wsdd
5- put the jar into axis lib
6- restart the tomcat.
--- Raúl García <[EMAIL PROTECTED]> escreveu:
> Hi all,
>
> I need to know how to create the java Proxy to make
> a remote call to a
> webservice.
>
> I know this is a simple action but I cannot
> understand the documentation
> very well.
> Can please someone send us a tutorial or some
> example code to do that?
>
> Thanks on advance
> Regards
> Raúl
>
>
>
Felipe F. Palma Dias - São Paulo/SP
http://www.palmadias.com.br
MSN: [EMAIL PROTECTED]
Yahoo: palmadias
Mobile: +55 11 99157578
_______________________________________________________
Novo Yahoo! Messenger com voz: ligações, Yahoo! Avatars, novos emoticons e
muito mais. Instale agora!
www.yahoo.com.br/messenger/
<?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://longhorn/" 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://longhorn/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://longhorn/">
<s:element name="Add">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="a" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="b" 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: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:portType name="prueba1Soap">
<wsdl:operation name="Add">
<wsdl:input message="tns:AddSoapIn" />
<wsdl:output message="tns:AddSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="prueba1Soap" type="tns:prueba1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Add">
<soap:operation soapAction="http://longhorn/Add" 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="prueba1Soap12" type="tns:prueba1Soap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Add">
<soap12:operation soapAction="http://longhorn/Add" 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="prueba1">
<wsdl:port name="prueba1Soap" binding="tns:prueba1Soap">
<soap:address location="http://192.168.21.15/prueba1/NewFile.asmx" />
</wsdl:port>
<wsdl:port name="prueba1Soap12" binding="tns:prueba1Soap12">
<soap12:address location="http://192.168.21.15/prueba1/NewFile.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>