Hi All,
I want to deploy a sample "dynamic" hotDeploy service in
rpc/literal style.
The client use this style. And i can't change this situation.
I try this command in createService() method to set rpc style:
axisoperation.setStyle(AxisOperation.STYLE_RPC);
"The wsdl that gets auto generated by Axis2 specifes
document/literal and calling the service results in a
document/literal message." (see:
http://marc.info/?l=axis-user&m=117929253910941&w=2)
I use Axis2 1.2 build (April 27 2007).
I hope someone can help.
regards
Bay
.
.
///////////////////////////////////////////////////////////////////
echoString.java
-------------------------------------------------------------------
public class echoString {
public String echoString(String input) {
System.out.println("EchoString Service called: in:" +
input); return input;
} }
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
Main.java
-------------------------------------------------------------------
UtilServer utilServer = null;
final static String AXIS2_HOME = "D:\\axisServer";
final static String repository = AXIS2_HOME + "\\repository";
final static String axis2Conf = AXIS2_HOME + "\\conf\\axis2.xml";
private void startServer(){
utilServer = new UtilServer();
utilServer.start(repository,axis2Conf);
}
private void deployService(){
ConfigurationContext context = utilServer.getConfigurationContext();
AxisService service=null;
service = createService(
echoString.class.getName(),
context.getAxisConfiguration(),
RPCMessageReceiver.class,
"ns1",
"http://soapinterop.org/"
);
utilServer.deployService(service);
}
public static AxisService createService(
String implClass,
AxisConfiguration axisConfig,
Class messageReceiverClass,
String targetNameSpace,
String schemaNameSpace ) throws AxisFault {
Parameter parameter = new Parameter(Constants.SERVICE_CLASS,
implClass);
OMElement paraElement = Utils.getParameter(Constants.SERVICE_CLASS,
implClass, false);
parameter.setParameterElement(paraElement);
AxisService axisService = new AxisService();
axisService.setUseDefaultChains(false);
axisService.addParameter(parameter);
if (schemaNameSpace == null) {
schemaNameSpace = axisService.getSchematargetNamespace();
}
int index = implClass.lastIndexOf(".");
String serviceName;
if (index > 0) {
serviceName = implClass.substring(index + 1, implClass.length());
} else {
serviceName = implClass;
}
axisService.setName(serviceName);
axisService.setClassLoader(axisConfig.getServiceClassLoader());
ClassLoader serviceClassLoader = axisService.getClassLoader();
ArrayList excludeOpeartion = new ArrayList();
NamespaceMap map = new NamespaceMap();
map.put(Java2WSDLConstants.AXIS2_NAMESPACE_PREFIX,
Java2WSDLConstants.AXIS2_XSD);
map.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX,
Java2WSDLConstants.URI_2001_SCHEMA_XSD);
axisService.setNameSpacesMap(map);
SchemaGenerator schemaGenerator; try {
schemaGenerator = new SchemaGenerator(serviceClassLoader,
implClass, schemaNameSpace,
axisService.getSchematargetNamespacePrefix());
schemaGenerator.setElementFormDefault(Java2WSDLConstants.FORM_DEFAULT_UNQUALIFIED);
axisService.setElementFormDefault(false);
Utils.addExclueMethods(excludeOpeartion);
schemaGenerator.setExcludeMethods(excludeOpeartion);
axisService.addSchema(schemaGenerator.generateSchema());
axisService.setSchematargetNamespace(schemaGenerator.getSchemaTargetNameSpace());
axisService.setTypeTable(schemaGenerator.getTypeTable());
if (targetNameSpace == null) {
targetNameSpace = schemaGenerator.getSchemaTargetNameSpace();
}
if (targetNameSpace != null && !"".equals(targetNameSpace)) {
axisService.setTargetNamespace(targetNameSpace);
}
} catch (Exception e) {
throw new AxisFault(e);
}
JMethod[] method = schemaGenerator.getMethods();
TypeTable table = schemaGenerator.getTypeTable();
PhasesInfo pinfo = axisConfig.getPhasesInfo();
for (int i = 0; i < method.length; i++) {
JMethod jmethod = method[i];
JAnnotation methodAnnon =
jmethod.getAnnotation(AnnotationConstants.WEB_METHOD);
if (methodAnnon != null) {
if
(methodAnnon.getValue(AnnotationConstants.EXCLUDE).asBoolean()) {
continue;
}
}
if (!jmethod.isPublic()) {
continue;
} else if (excludeOpeartion.contains(jmethod.getSimpleName())) {
continue;
}
AxisOperation axisoperation =
Utils.getAxisOperationforJmethod(jmethod, table);
axisoperation.setStyle(AxisOperation.STYLE_RPC);
System.out.println("style:" + axisoperation.getStyle());
// loading message receivers
try {
MessageReceiver messageReceiver =
(MessageReceiver) messageReceiverClass.newInstance();
axisoperation.setMessageReceiver(messageReceiver);
} catch (IllegalAccessException e) {
throw new AxisFault(
"IllegalAccessException occurred during message
receiver loading"
+ e.getMessage());
} catch (InstantiationException e) {
throw new AxisFault(
"InstantiationException occurred during message
receiver loading"
+ e.getMessage());
}
pinfo.setOperationPhases(axisoperation);
axisService.addOperation(axisoperation);
}
return axisService;
}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
UtilServer.java
-------------------------------------------------------------------
private static SimpleHTTPServer receiver;
.
.
.
public static synchronized void start(String repository, String
axis2xml) throws Exception {
System.out.println("UtilServer,start(,) repository:" + repository
+ ", axis2.xml:" + axis2xml);
if (count == 0) {
ConfigurationContext er =
getNewConfigurationContext(repository, axis2xml);
er.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
er.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);
receiver = new SimpleHTTPServer(er, ServerPort);
try {
receiver.start();
//System.out.println("Server started on port " + ServerPort
+ ".....");
} catch (Exception e) {
throw new AxisFault(e);
}
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
throw new AxisFault("Thread interuptted", e1);
}
}
count++;
}
.
. public static synchronized void deployService(AxisService service)
throws AxisFault {
receiver.getConfigurationContext().getAxisConfiguration().addService(service);
} ///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
http://localhost:8080/../echoString?wsdl
-------------------------------------------------------------------
- <wsdl:definitions xmlns:axis2="ns1"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:ns0="http://soapinterop.org/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ns1="http://org.apache.axis2/xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="ns1">
- <wsdl:types>
- <xs:schema xmlns:ns="http://soapinterop.org/"
attributeFormDefault="qualified" elementFormDefault="unqualified"
targetNamespace="http://soapinterop.org/">
- <xs:element name="echoString">
- <xs:complexType>
- <xs:sequence>
<xs:element name="input" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="echoStringResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element name="return" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
- <wsdl:message name="echoStringMessage">
<wsdl:part name="part1" element="ns0:echoString" />
</wsdl:message>
- <wsdl:message name="echoStringResponse">
<wsdl:part name="part1" element="ns0:echoStringResponse" />
</wsdl:message>
- <wsdl:portType name="echoStringPortType">
- <wsdl:operation name="echoString">
<wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
message="axis2:echoStringMessage" wsaw:Action="urn:echoString" />
<wsdl:output message="axis2:echoStringResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="echoStringSOAP11Binding"
type="axis2:echoStringPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
- <wsdl:operation name="echoString">
<soap:operation soapAction="urn:echoString" 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="echoStringSOAP12Binding"
type="axis2:echoStringPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
- <wsdl:operation name="echoString">
<soap12:operation soapAction="urn:echoString" 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="echoStringHttpBinding"
type="axis2:echoStringPortType">
<http:binding verb="POST" />
- <wsdl:operation name="echoString">
<http:operation location="echoString" />
- <wsdl:input>
<mime:content type="text/xml" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="echoString">
- <wsdl:port name="echoStringSOAP11port_http"
binding="axis2:echoStringSOAP11Binding">
<soap:address location="http://localhost:8080/../echoString" />
</wsdl:port>
- <wsdl:port name="echoStringSOAP12port_http"
binding="axis2:echoStringSOAP12Binding">
<soap12:address location="http://localhost:8080/../echoString" />
</wsdl:port>
- <wsdl:port name="echoStringHttpport"
binding="axis2:echoStringHttpBinding">
<http:address location="http://localhost:8080/../echoString" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
Request:
-------------------------------------------------------------------
POST /axis2/services/echoString HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "urn:Services#echoString"
User-Agent: Axis2
Host: localhost:4040
Transfer-Encoding: chunked
111
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:echoString xmlns:ns1="http://soapinterop.org/">
<ns1:String>Axis2 Echo String</ns1:String>
</ns1:echoString>
</soapenv:Body>
</soapenv:Envelope>0
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
Response:
-------------------------------------------------------------------
HTTP/1.1 200 OK
Date: Wed, 11 Jul 2007 19:54:36 GMT
Server: Simple-Server/1.1
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
116
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:echoStringResponse xmlns:ns="http://soapinterop.org/">
<return>Axis2 Echo String</return>
</ns:echoStringResponse>
</soapenv:Body>
</soapenv:Envelope>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]