You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Gordon Brown <go...@yahoo.com> on 2011/03/03 00:51:50 UTC
axis2/java service client set operation
Hi All,
I am using axis2/java to build a web service client component. I have a
question.
Is there a way to set the operation name in the web service client?
Using axis/j, I can do something like this:
org.apache.axis.client.Service soapService = new
org.apache.axis.client.Service();
soapService.createCall();
call = soapService.getCall();
call.setTargetEndpointAddress(soapAddress);
//setting operation name in the call object
call.setOperationName(new QName(operationNamespace, operationName));
call.setSOAPActionURI(soapAction);
call.setPortName(new QName(portNamespaceURI,portName));
But in axis2/java, I don't see how I can set the operation name in the service
client. I got an exception when trying to do this:
ServiceClient serviceClient = new ServiceClient();
//The following line get an exception, try to set operation name in
the service client
OperationClient operationClient = serviceClient.createClient(new
QName(operationNamespace, operationName));
operationClient.getOptions().setAction(soapAction);
operationClient.getOptions().setTo(new EndpointReference(soapAddress));
operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
I understand that the server side might not need the operation name, it can
use soapAction et cetera to figure out where to dispatch the message. But how
about the client doesn't know the soapAction (it might not even have one), all
it know is the operation name, in which case the server will have to rely on the
operation name (as the last resort), right?
Your help is much appreciated.
Gordon
RE: axis2/java service client set operation
Posted by Martin Gainty <mg...@hotmail.com>.
you can assign the serviceName attribute when annotating your service with
import javax.jws.WebService;
@WebService(serviceName = "EchoMessageService", portName = "EchoMessagePort", targetNamespace = "http://nonanonymous.complextype.test.org", wsdlLocation = "test-resources/wsdl/EchoMessageService.wsdl")
public class EchoMessageService {
public String echoMessage(String arg) {
return arg;
}
}
client call:
org.apache.axis2.jaxws.description.impl.EndpointInterfaceDescription testEndpointInterfaceDesc=getEndpointInterfaceDesc(EchoMessageService.class);
org.apache.axis2.jaxws.description.OperationDescription[] operationDescs=testEndpointInterfaceDesc.getOperations();
//select the method you want and execute it
/* Method to return the endpoint interface description for a given implementation class.*/
private EndpointInterfaceDescription getEndpointInterfaceDesc(Class implementationClass)
{
// Use the description factory directly; this will be done within the JAX-WS runtime
ServiceDescription serviceDesc =
DescriptionFactory.createServiceDescription(implementationClass);
assertNotNull(serviceDesc);
EndpointDescription[] endpointDesc = serviceDesc.getEndpointDescriptions();
assertNotNull(endpointDesc);
assertEquals(1, endpointDesc.length);
// TODO: How will the JAX-WS dispatcher get the appropriate port (i.e. endpoint)? Currently assumes [0]
EndpointDescription testEndpointDesc = endpointDesc[0];
EndpointInterfaceDescription testEndpointInterfaceDesc =
testEndpointDesc.getEndpointInterfaceDescription();
assertNotNull(testEndpointInterfaceDesc);
return testEndpointInterfaceDesc;
}
}
//in the end it seems you are seeking perhaps a more (tightly bound) RPC naming convention
//than allowing the conventional service->port->operation->message assignment from the wsdl in other words
//Service->PortType->operation->InputMessage and OutputMessage
<definitions targetNamespace="http://nonanonymous.complextype.test.org" xmlns:tns="http://nonanonymous.complextype.test.org" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://nonanonymous.complextype.test.org" xmlns:ts="http://nonanonymous.complextype.test.org/xsd" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<complexType name="echoMessage">
<sequence>
<element name="request" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="echoMessageResponse">
<sequence>
<element name="response" type="xsd:string"/>
</sequence>
</complexType>
<element name="echoMessage" type="tns:echoMessage"/>
<element name="echoMessageResponse" type="tns:echoMessageResponse"/>
</xsd:schema>
</types>
<message name="echoMessage">
<part name="message" element="tns:echoMessage"/>
</message>
<message name="echoMessageResponse">
<part name="result" element="tns:echoMessageResponse"/>
</message>
<portType name="EchoMessagePortType">
<operation name="echoMessage">
<input message="tns:echoMessage" />
<output message="tns:echoMessageResponse" />
</operation>
</portType>
<binding name="EchoMessageBinding" type="tns:EchoMessagePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="echoMessage">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="EchoMessageService">
<port binding="tns:EchoMessageBinding" name="EchoMessagePort">
<soap:address location="http://localhost:8080/EchoMessageService/EchoMessageService"/>
</port>
</service>
</definitions>
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az
üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
Date: Thu, 3 Mar 2011 11:11:06 -0800
From: gordonw.brown@yahoo.com
Subject: Re: axis2/java service client set operation
To: java-user@axis.apache.org; java-dev@axis.apache.org
Martin,
You example is exactly what I used with axis/java 1.4. But now I am using AXIS2/Java, and AXIS2/Java doesn't seem to have these APIs any more.
Thanks!
Gordon
From: Martin Gainty <mg...@hotmail.com>
To: java-dev@axis.apache.org; java-user@axis.apache.org
Sent: Wed, March 2, 2011 4:57:17 PM
Subject: RE: axis2/java service client set operation
try this ..
String port = "4444"; //port the TCP mon listens
String SOAPAction = "Service"; //service name
String endpoint = "http://127.0.0.1:" + port + "/service/servlet/AxisServlet";
//create the service
Service service = new Service();
//create the call for the service
call = (Call) service.createCall();
//set the EPR of the call
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//set the URI for SOAPAction
call.setSOAPActionURI(SOAPAction);
//create a Qualified Name
QName method = new QName("someuri",
"add");
//set the operation name to the constructed Qualified Name
call.setOperationName(method);
cheers,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
Date: Wed, 2 Mar 2011 15:51:50 -0800
From: gordonw.brown@yahoo.com
Subject: axis2/java service client set operation
To: java-user@axis.apache.org
CC: java-dev@axis.apache.org
Hi All,
I am using axis2/java to build a web service client component. I have a question.
Is there a way to set the operation name in the web service client?
Using axis/j, I can do something like this:
org.apache.axis.client.Service soapService = new org.apache.axis.client.Service();
soapService.createCall();
call = soapService.getCall();
call.setTargetEndpointAddress(soapAddress);
//setting operation name in the call object
call.setOperationName(new QName(operationNamespace, operationName));
call.setSOAPActionURI(soapAction);
call.setPortName(new QName(portNamespaceURI,portName));
But in axis2/java, I don't see how I can set the operation name in the service client. I got an exception when trying to do this:
ServiceClient serviceClient = new ServiceClient();
//The following line get an exception, try to set operation name in the service client
OperationClient operationClient = serviceClient.createClient(new QName(operationNamespace, operationName));
operationClient.getOptions().setAction(soapAction);
operationClient.getOptions().setTo(new EndpointReference(soapAddress));
operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
I understand that the server side might not need the operation name, it can use soapAction et cetera to figure out where to dispatch the message. But how about the client doesn't know the soapAction (it might not even have one), all it know is the operation name, in which case the server will have to rely on the operation name (as the last resort), right?
Your help is much appreciated.
Gordon
RE: axis2/java service client set operation
Posted by Martin Gainty <mg...@hotmail.com>.
you can assign the serviceName attribute when annotating your service with
import javax.jws.WebService;
@WebService(serviceName = "EchoMessageService", portName = "EchoMessagePort", targetNamespace = "http://nonanonymous.complextype.test.org", wsdlLocation = "test-resources/wsdl/EchoMessageService.wsdl")
public class EchoMessageService {
public String echoMessage(String arg) {
return arg;
}
}
client call:
org.apache.axis2.jaxws.description.impl.EndpointInterfaceDescription testEndpointInterfaceDesc=getEndpointInterfaceDesc(EchoMessageService.class);
org.apache.axis2.jaxws.description.OperationDescription[] operationDescs=testEndpointInterfaceDesc.getOperations();
//select the method you want and execute it
/* Method to return the endpoint interface description for a given implementation class.*/
private EndpointInterfaceDescription getEndpointInterfaceDesc(Class implementationClass)
{
// Use the description factory directly; this will be done within the JAX-WS runtime
ServiceDescription serviceDesc =
DescriptionFactory.createServiceDescription(implementationClass);
assertNotNull(serviceDesc);
EndpointDescription[] endpointDesc = serviceDesc.getEndpointDescriptions();
assertNotNull(endpointDesc);
assertEquals(1, endpointDesc.length);
// TODO: How will the JAX-WS dispatcher get the appropriate port (i.e. endpoint)? Currently assumes [0]
EndpointDescription testEndpointDesc = endpointDesc[0];
EndpointInterfaceDescription testEndpointInterfaceDesc =
testEndpointDesc.getEndpointInterfaceDescription();
assertNotNull(testEndpointInterfaceDesc);
return testEndpointInterfaceDesc;
}
}
//in the end it seems you are seeking perhaps a more (tightly bound) RPC naming convention
//than allowing the conventional service->port->operation->message assignment from the wsdl in other words
//Service->PortType->operation->InputMessage and OutputMessage
<definitions targetNamespace="http://nonanonymous.complextype.test.org" xmlns:tns="http://nonanonymous.complextype.test.org" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://nonanonymous.complextype.test.org" xmlns:ts="http://nonanonymous.complextype.test.org/xsd" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<complexType name="echoMessage">
<sequence>
<element name="request" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="echoMessageResponse">
<sequence>
<element name="response" type="xsd:string"/>
</sequence>
</complexType>
<element name="echoMessage" type="tns:echoMessage"/>
<element name="echoMessageResponse" type="tns:echoMessageResponse"/>
</xsd:schema>
</types>
<message name="echoMessage">
<part name="message" element="tns:echoMessage"/>
</message>
<message name="echoMessageResponse">
<part name="result" element="tns:echoMessageResponse"/>
</message>
<portType name="EchoMessagePortType">
<operation name="echoMessage">
<input message="tns:echoMessage" />
<output message="tns:echoMessageResponse" />
</operation>
</portType>
<binding name="EchoMessageBinding" type="tns:EchoMessagePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="echoMessage">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="EchoMessageService">
<port binding="tns:EchoMessageBinding" name="EchoMessagePort">
<soap:address location="http://localhost:8080/EchoMessageService/EchoMessageService"/>
</port>
</service>
</definitions>
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az
üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
Date: Thu, 3 Mar 2011 11:11:06 -0800
From: gordonw.brown@yahoo.com
Subject: Re: axis2/java service client set operation
To: java-user@axis.apache.org; java-dev@axis.apache.org
Martin,
You example is exactly what I used with axis/java 1.4. But now I am using AXIS2/Java, and AXIS2/Java doesn't seem to have these APIs any more.
Thanks!
Gordon
From: Martin Gainty <mg...@hotmail.com>
To: java-dev@axis.apache.org; java-user@axis.apache.org
Sent: Wed, March 2, 2011 4:57:17 PM
Subject: RE: axis2/java service client set operation
try this ..
String port = "4444"; //port the TCP mon listens
String SOAPAction = "Service"; //service name
String endpoint = "http://127.0.0.1:" + port + "/service/servlet/AxisServlet";
//create the service
Service service = new Service();
//create the call for the service
call = (Call) service.createCall();
//set the EPR of the call
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//set the URI for SOAPAction
call.setSOAPActionURI(SOAPAction);
//create a Qualified Name
QName method = new QName("someuri",
"add");
//set the operation name to the constructed Qualified Name
call.setOperationName(method);
cheers,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
Date: Wed, 2 Mar 2011 15:51:50 -0800
From: gordonw.brown@yahoo.com
Subject: axis2/java service client set operation
To: java-user@axis.apache.org
CC: java-dev@axis.apache.org
Hi All,
I am using axis2/java to build a web service client component. I have a question.
Is there a way to set the operation name in the web service client?
Using axis/j, I can do something like this:
org.apache.axis.client.Service soapService = new org.apache.axis.client.Service();
soapService.createCall();
call = soapService.getCall();
call.setTargetEndpointAddress(soapAddress);
//setting operation name in the call object
call.setOperationName(new QName(operationNamespace, operationName));
call.setSOAPActionURI(soapAction);
call.setPortName(new QName(portNamespaceURI,portName));
But in axis2/java, I don't see how I can set the operation name in the service client. I got an exception when trying to do this:
ServiceClient serviceClient = new ServiceClient();
//The following line get an exception, try to set operation name in the service client
OperationClient operationClient = serviceClient.createClient(new QName(operationNamespace, operationName));
operationClient.getOptions().setAction(soapAction);
operationClient.getOptions().setTo(new EndpointReference(soapAddress));
operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
I understand that the server side might not need the operation name, it can use soapAction et cetera to figure out where to dispatch the message. But how about the client doesn't know the soapAction (it might not even have one), all it know is the operation name, in which case the server will have to rely on the operation name (as the last resort), right?
Your help is much appreciated.
Gordon
Re: axis2/java service client set operation
Posted by Gordon Brown <go...@yahoo.com>.
Martin,
You example is exactly what I used with axis/java 1.4. But now I am using
AXIS2/Java, and AXIS2/Java doesn't seem to have these APIs any more.
Thanks!
Gordon
________________________________
From: Martin Gainty <mg...@hotmail.com>
To: java-dev@axis.apache.org; java-user@axis.apache.org
Sent: Wed, March 2, 2011 4:57:17 PM
Subject: RE: axis2/java service client set operation
try this ..
String port = "4444"; //port the TCP mon listens
String SOAPAction = "Service"; //service name
String endpoint = "http://127.0.0.1:" + port +
"/service/servlet/AxisServlet";
//create the service
Service service = new Service();
//create the call for the service
call = (Call) service.createCall();
//set the EPR of the call
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//set the URI for SOAPAction
call.setSOAPActionURI(SOAPAction);
//create a Qualified Name
QName method = new QName("someuri", "add");
//set the operation name to the constructed Qualified Name
call.setOperationName(method);
cheers,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note
de déni et de confidentialité
Ez az üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése nem
megengedett. Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi
alkalmazhatósága sincs. Mivel az electronikus üzenetek könnyen
megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet
tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
________________________________
Date: Wed, 2 Mar 2011 15:51:50 -0800
From: gordonw.brown@yahoo.com
Subject: axis2/java service client set operation
To: java-user@axis.apache.org
CC: java-dev@axis.apache.org
Hi All,
I am using axis2/java to build a web service client component. I have a
question.
Is there a way to set the operation name in the web service client?
Using axis/j, I can do something like this:
org.apache.axis.client.Service soapService = new
org.apache.axis.client.Service();
soapService.createCall();
call = soapService.getCall();
call.setTargetEndpointAddress(soapAddress);
//setting operation name in the call object
call.setOperationName(new QName(operationNamespace, operationName));
call.setSOAPActionURI(soapAction);
call.setPortName(new QName(portNamespaceURI,portName));
But in axis2/java, I don't see how I can set the operation name in the service
client. I got an exception when trying to do this:
ServiceClient serviceClient = new ServiceClient();
//The following line get an exception, try to set operation name in
the service client
OperationClient operationClient = serviceClient.createClient(new
QName(operationNamespace, operationName));
operationClient.getOptions().setAction(soapAction);
operationClient.getOptions().setTo(new EndpointReference(soapAddress));
operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
I understand that the server side might not need the operation name, it can
use soapAction et cetera to figure out where to dispatch the message. But how
about the client doesn't know the soapAction (it might not even have one), all
it know is the operation name, in which case the server will have to rely on the
operation name (as the last resort), right?
Your help is much appreciated.
Gordon
Re: axis2/java service client set operation
Posted by Gordon Brown <go...@yahoo.com>.
Martin,
You example is exactly what I used with axis/java 1.4. But now I am using
AXIS2/Java, and AXIS2/Java doesn't seem to have these APIs any more.
Thanks!
Gordon
________________________________
From: Martin Gainty <mg...@hotmail.com>
To: java-dev@axis.apache.org; java-user@axis.apache.org
Sent: Wed, March 2, 2011 4:57:17 PM
Subject: RE: axis2/java service client set operation
try this ..
String port = "4444"; //port the TCP mon listens
String SOAPAction = "Service"; //service name
String endpoint = "http://127.0.0.1:" + port +
"/service/servlet/AxisServlet";
//create the service
Service service = new Service();
//create the call for the service
call = (Call) service.createCall();
//set the EPR of the call
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//set the URI for SOAPAction
call.setSOAPActionURI(SOAPAction);
//create a Qualified Name
QName method = new QName("someuri", "add");
//set the operation name to the constructed Qualified Name
call.setOperationName(method);
cheers,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note
de déni et de confidentialité
Ez az üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése nem
megengedett. Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi
alkalmazhatósága sincs. Mivel az electronikus üzenetek könnyen
megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet
tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
________________________________
Date: Wed, 2 Mar 2011 15:51:50 -0800
From: gordonw.brown@yahoo.com
Subject: axis2/java service client set operation
To: java-user@axis.apache.org
CC: java-dev@axis.apache.org
Hi All,
I am using axis2/java to build a web service client component. I have a
question.
Is there a way to set the operation name in the web service client?
Using axis/j, I can do something like this:
org.apache.axis.client.Service soapService = new
org.apache.axis.client.Service();
soapService.createCall();
call = soapService.getCall();
call.setTargetEndpointAddress(soapAddress);
//setting operation name in the call object
call.setOperationName(new QName(operationNamespace, operationName));
call.setSOAPActionURI(soapAction);
call.setPortName(new QName(portNamespaceURI,portName));
But in axis2/java, I don't see how I can set the operation name in the service
client. I got an exception when trying to do this:
ServiceClient serviceClient = new ServiceClient();
//The following line get an exception, try to set operation name in
the service client
OperationClient operationClient = serviceClient.createClient(new
QName(operationNamespace, operationName));
operationClient.getOptions().setAction(soapAction);
operationClient.getOptions().setTo(new EndpointReference(soapAddress));
operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
I understand that the server side might not need the operation name, it can
use soapAction et cetera to figure out where to dispatch the message. But how
about the client doesn't know the soapAction (it might not even have one), all
it know is the operation name, in which case the server will have to rely on the
operation name (as the last resort), right?
Your help is much appreciated.
Gordon
RE: axis2/java service client set operation
Posted by Martin Gainty <mg...@hotmail.com>.
try this ..
String port = "4444"; //port the TCP mon listens
String SOAPAction = "Service"; //service name
String endpoint = "http://127.0.0.1:" + port + "/service/servlet/AxisServlet";
//create the service
Service service = new Service();
//create the call for the service
call = (Call) service.createCall();
//set the EPR of the call
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//set the URI for SOAPAction
call.setSOAPActionURI(SOAPAction);
//create a Qualified Name
QName method = new QName("someuri", "add");
//set the operation name to the constructed Qualified Name
call.setOperationName(method);
cheers,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az
üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
Date: Wed, 2 Mar 2011 15:51:50 -0800
From: gordonw.brown@yahoo.com
Subject: axis2/java service client set operation
To: java-user@axis.apache.org
CC: java-dev@axis.apache.org
Hi All,
I am using axis2/java to build a web service client component. I have a question.
Is there a way to set the operation name in the web service client?
Using axis/j, I can do something like this:
org.apache.axis.client.Service soapService = new org.apache.axis.client.Service();
soapService.createCall();
call = soapService.getCall();
call.setTargetEndpointAddress(soapAddress);
//setting operation name in the call object
call.setOperationName(new QName(operationNamespace, operationName));
call.setSOAPActionURI(soapAction);
call.setPortName(new QName(portNamespaceURI,portName));
But in axis2/java, I don't see how I can set the operation name in the service client. I got an exception when trying to do this:
ServiceClient serviceClient = new ServiceClient();
//The following line get an exception, try to set operation name in the service client
OperationClient operationClient = serviceClient.createClient(new QName(operationNamespace, operationName));
operationClient.getOptions().setAction(soapAction);
operationClient.getOptions().setTo(new EndpointReference(soapAddress));
operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
I understand that the server side might not need the operation name, it can use soapAction et cetera to figure out where to dispatch the message. But how about the client doesn't know the soapAction (it might not even have one), all it know is the operation name, in which case the server will have to rely on the operation name (as the last resort), right?
Your help is much appreciated.
Gordon
Re: axis2/java service client set operation
Posted by Gordon Brown <go...@yahoo.com>.
Hi Sagara,
When you say "You can make operation name part of the EPR ", you mean I can do
the following?
Say I have an service endpoint:
http://host:port/xyz24/webservices1.5?soap=Map24Geocoder51&wsdl_version=2.0
And I have an operation: RetrieveAddress
I can construct a new endpoint:
http://host:port/xyz24/webservices1.5?soap=Map24Geocoder51&wsdl_version=2.0/RetrieveAddress
I have two questions on this:
(1) Operation can have a namespace, how to pass that namespace info? I am asking
this because I have a web service server that depends on the operation name and
the operation namespace to dispatch the web services. Their WSDL does not define
a soap action.
Still, my basic question is: Is there a way in AXIS2/java that we can pass the
operation info (name/namespace) in the web service client call.
(2) The query string is in the middle of the endpoint URL now, will this cause
problem?
Thanks!
Frank
________________________________
From: Sagara Gunathunga <sa...@gmail.com>
To: java-user@axis.apache.org
Cc: Gordon Brown <go...@yahoo.com>
Sent: Wed, March 2, 2011 11:00:55 PM
Subject: Re: axis2/java service client set operation
Hi Gordonw,
Axis2 server side use several criteria to dispatch incoming messages,
"soapAction" is one of them take a look [1]. In fact soapAction is mandatory in
SOAP 1.1 but replaced in SOAP 1.2 using a optional "action". So your client can
send one of above input data according to underline dispatching approach.
You can make operation name part of the EPR as follows.
ServiceClient sender = new ServiceClient();
Options options = new Options();
options.setTo(new EndpointReference("http://host/MyService/MyOperation"));
sender.setOptions(options);
[1] - http://wso2.org/library/176
Thanks !
On Thu, Mar 3, 2011 at 5:21 AM, Gordon Brown <go...@yahoo.com> wrote:
Hi All,
>
>I am using axis2/java to build a web service client component. I have a
>question.
>
>Is there a way to set the operation name in the web service client?
>
>Using axis/j, I can do something like this:
>
> org.apache.axis.client.Service soapService = new
>org.apache.axis.client.Service();
> soapService.createCall();
> call = soapService.getCall();
> call.setTargetEndpointAddress(soapAddress);
>
> //setting operation name in the call object
> call.setOperationName(new QName(operationNamespace, operationName));
>
> call.setSOAPActionURI(soapAction);
> call.setPortName(new QName(portNamespaceURI,portName));
>
>But in axis2/java, I don't see how I can set the operation name in the service
>client. I got an exception when trying to do this:
>
> ServiceClient serviceClient = new ServiceClient();
>
> //The following line get an exception, try to set operation name in
>the service client
> OperationClient operationClient = serviceClient.createClient(new
>QName(operationNamespace, operationName));
>
> operationClient.getOptions().setAction(soapAction);
> operationClient.getOptions().setTo(new EndpointReference(soapAddress));
> operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
>
>operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
>
>I understand that the server side might not need the operation name, it can
>use soapAction et cetera to figure out where to dispatch the message. But how
>about the client doesn't know the soapAction (it might not even have one), all
>it know is the operation name, in which case the server will have to rely on the
>operation name (as the last resort), right?
>
>Your help is much appreciated.
>Gordon
>
>
--
Sagara Gunathunga
Blog - http://ssagara.blogspot.com
Web - http://people.apache.org/~sagara/
Re: axis2/java service client set operation
Posted by Sagara Gunathunga <sa...@gmail.com>.
Hi Gordonw,
Axis2 server side use several criteria to dispatch incoming messages,
"soapAction" is one of them take a look [1]. In fact soapAction is
mandatory in SOAP 1.1 but replaced in SOAP 1.2 using a optional "action". So
your client can send one of above input data according to underline
dispatching approach.
You can make operation name part of the EPR as follows.
ServiceClient sender = new ServiceClient();
Options options = new Options();
options.setTo(new EndpointReference("http://host/MyService/MyOperation"));
sender.setOptions(options);
[1] - http://wso2.org/library/176
Thanks !
On Thu, Mar 3, 2011 at 5:21 AM, Gordon Brown <go...@yahoo.com>wrote:
> Hi All,
>
> I am using axis2/java to build a web service client component. I have a
> question.
>
> Is there a way to set the operation name in the web service client?
>
> Using axis/j, I can do something like this:
>
> org.apache.axis.client.Service soapService = new
> org.apache.axis.client.Service();
> soapService.createCall();
> call = soapService.getCall();
> call.setTargetEndpointAddress(soapAddress);
>
> //setting operation name in the call object
> call.setOperationName(new QName(operationNamespace,
> operationName));
>
> call.setSOAPActionURI(soapAction);
> call.setPortName(new QName(portNamespaceURI,portName));
>
> But in axis2/java, I don't see how I can set the operation name in the
> service client. I got an exception when trying to do this:
>
> ServiceClient serviceClient = new ServiceClient();
>
> //The following line get an exception, try to set operation name in
> the service client
> OperationClient operationClient = serviceClient.createClient(new
> QName(operationNamespace, operationName));
>
> operationClient.getOptions().setAction(soapAction);
> operationClient.getOptions().setTo(new
> EndpointReference(soapAddress));
>
> operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
>
> operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
> I understand that the server side might not need the operation name, it can
> use soapAction et cetera to figure out where to dispatch the message. But
> how about the client doesn't know the soapAction (it might not even have
> one), all it know is the operation name, in which case the server will have
> to rely on the operation name (as the last resort), right?
>
> Your help is much appreciated.
> Gordon
>
>
>
--
Sagara Gunathunga
Blog - http://ssagara.blogspot.com
Web - http://people.apache.org/~sagara/
RE: axis2/java service client set operation
Posted by Martin Gainty <mg...@hotmail.com>.
try this ..
String port = "4444"; //port the TCP mon listens
String SOAPAction = "Service"; //service name
String endpoint = "http://127.0.0.1:" + port + "/service/servlet/AxisServlet";
//create the service
Service service = new Service();
//create the call for the service
call = (Call) service.createCall();
//set the EPR of the call
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//set the URI for SOAPAction
call.setSOAPActionURI(SOAPAction);
//create a Qualified Name
QName method = new QName("someuri", "add");
//set the operation name to the constructed Qualified Name
call.setOperationName(method);
cheers,
Martin Gainty
______________________________________________
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Ez az
üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
Date: Wed, 2 Mar 2011 15:51:50 -0800
From: gordonw.brown@yahoo.com
Subject: axis2/java service client set operation
To: java-user@axis.apache.org
CC: java-dev@axis.apache.org
Hi All,
I am using axis2/java to build a web service client component. I have a question.
Is there a way to set the operation name in the web service client?
Using axis/j, I can do something like this:
org.apache.axis.client.Service soapService = new org.apache.axis.client.Service();
soapService.createCall();
call = soapService.getCall();
call.setTargetEndpointAddress(soapAddress);
//setting operation name in the call object
call.setOperationName(new QName(operationNamespace, operationName));
call.setSOAPActionURI(soapAction);
call.setPortName(new QName(portNamespaceURI,portName));
But in axis2/java, I don't see how I can set the operation name in the service client. I got an exception when trying to do this:
ServiceClient serviceClient = new ServiceClient();
//The following line get an exception, try to set operation name in the service client
OperationClient operationClient = serviceClient.createClient(new QName(operationNamespace, operationName));
operationClient.getOptions().setAction(soapAction);
operationClient.getOptions().setTo(new EndpointReference(soapAddress));
operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
operationClient.getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
I understand that the server side might not need the operation name, it can use soapAction et cetera to figure out where to dispatch the message. But how about the client doesn't know the soapAction (it might not even have one), all it know is the operation name, in which case the server will have to rely on the operation name (as the last resort), right?
Your help is much appreciated.
Gordon