function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BasilBasil 

creating internal web service using apache axis technology

I would like to create an internal webservice to provide other internal developers who don't have access to salesforce.com the functions they need to insert in salesforce.com

some developers use Java and others use .Net ...

providing them a wsdl file will allow them to develop in the environment they prefer.

I visted the ws.apache.org/axis site I've seen example on how to create the java to wsdl

but st'ill dont know how to generate these codes from java to wsdl.

for example I have this information:
< xsd:complexType name="phone" >
< xsd:all >
< xsd:element name="areaCode" type="xsd:int"/ >
< xsd:element name="exchange" type="xsd:string"/ >
< xsd:element name="number" type="xsd:string"/ >
< /xsd:all >
< /xsd:complexType >

WSDL2Java will generate:

public class Phone implements java.io.Serializable {
public Phone() {...}
public int getAreaCode() {...}
public void setAreaCode(int areaCode) {...}
public java.lang.String getExchange() {...}
public void setExchange(java.lang.String exchange) {...}
public java.lang.String getNumber() {...}
public void setNumber(java.lang.String number) {...}
public boolean equals(Object obj) {...}
public int hashCode() {...}
}

what I like is to have the java code example to generate this wsdl example:
< xsd:complexType name="phone" >
< xsd:all >
< xsd:element name="areaCode" type="xsd:int"/ >
< xsd:element name="exchange" type="xsd:string"/ >
< xsd:element name="number" type="xsd:string"/ >
< /xsd:all >
< /xsd:complexType >

the problem is when I use this java code example:
public java.lang.String getExchange() {...}
public void setExchange(java.lang.String exchange) {...}

java2wsdl generate this:
< xsd:operation name="getExchange" .../ >
< xsd:operation name="setExchange" .../ >

and its not what I want ... but simply something like this:
< xsd:element name="exchange" type="xsd:string"/ >

I want the developers to create the objects and set the fields without needing to connect to my webservice. Like your wsdl file, when we create for example a contact, the contact object is created and completed without needing to make make any connecton nor login. Once the developer has created their objects, they can post the information like we do iwith your web service using for example the create call.

the aim of my demand to make the minimum connection as possible to my webservice, the connection is used only when necessary, when the information is needed to be posted.
SuperfellSuperfell
define beans for your objects, then write your service class to take in and/or return these bean classes. Finally run java2wsdl on the results.

A better method (IMO) is to define the web service first in WSDL then use WSDL2Java to generate your server side stubs, this way no Java'ism's will creap into your service and trip up other languages (such as .NET etc)
BasilBasil
1) define beans for your objects,
--> I understand (implement serializable)

2) then write your service class to take in and/or return these bean classes.
--> ??? (sorry but I don't understand what do you mean by "to take in and/or return these bean classes", are you talking about get and set ???
can you please give me java code example depending on what I have written in the topic before, thanks

3) Finally run java2wsdl on the results.



A better method (IMO) is to define the web service first in WSDL then use WSDL2Java to generate your server side stubs, this way no Java'ism's will creap into your service and trip up other languages (such as .NET etc)

---> may be its a good idea, but I must create my web services in java and provide a wsdl file to the other devlopers when the web service is finished
SuperfellSuperfell
Don't use getters and settings, simply pass your bean as a parameter, e.g.

public BeanOne doStuff(MyOtherBean bean)
{
....
}

If you design the service first in WSDL, you can still give that WSDL to the developers. WSDL2Java can be used to create the skeleton server side implementation that you then fill in.

This is getting Off-topic for here, you might be better asking general Axis questions on the axis-users mailing list, see http://ws.apache.org/axis/mail.html
BasilBasil
I understand you and agree with you that the topics handle sforce and salesforce.com issues

it's just because I know that salesforce.com use Apache axis on server side, and I really hope that you will be able to solve my problem, I tried on Apache site without any succus


replying to your post:

in that case when the user want to use the doStuff function he'll have to access to the web service and its not what I want.

I'll have something like this in the wsdl file
< operation name="doStuff" ... / >

what I'm looking for is something like the sforce sObject java code on the server side
(not the complete one, just how to appear element instead of operation)


< sequence >
< element name="fieldsToNull" type="xsd:string" nillable="true" minOccurs="0"
maxOccurs="unbounded"/ >
< element name="Id" type="tns:ID" nillable="true" minOccurs="0" maxOccurs="1"/ >
< /sequence >
< /complexType >



which shows this on the client side:
(as you can see for example the id field will be able to be set without needing to access to the web service)

public abstract class SObject implements java.io.Serializable {
private java.lang.String[] fieldsToNull;
private com.sforce.soap.enterprise.ID id;

public SObject() {
}

public java.lang.String[] getFieldsToNull() {
return fieldsToNull;
}

public void setFieldsToNull(java.lang.String[] fieldsToNull) {
this.fieldsToNull = fieldsToNull;
}

public java.lang.String getFieldsToNull(int i) {
return fieldsToNull[i];
}

public void setFieldsToNull(int i, java.lang.String value) {
this.fieldsToNull[i] = value;
}

public com.sforce.soap.enterprise.ID getId() {
return id;
}

public void setId(com.sforce.soap.enterprise.ID id) {
this.id = id;
}

private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof SObject)) return false;
SObject other = (SObject) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this.fieldsToNull==null && other.getFieldsToNull()==null) ||
(this.fieldsToNull!=null &&
java.util.Arrays.equals(this.fieldsToNull, other.getFieldsToNull()))) &&
((this.id==null && other.getId()==null) ||
(this.id!=null &&
this.id.equals(other.getId())));
__equalsCalc = null;
return _equals;
}

private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (getFieldsToNull() != null) {
for (int i=0;
i i++) {
java.lang.Object obj = java.lang.reflect.Array.get(getFieldsToNull(), i);
if (obj != null &&
!obj.getClass().isArray()) {
_hashCode += obj.hashCode();
}
}
}
if (getId() != null) {
_hashCode += getId().hashCode();
}
__hashCodeCalc = false;
return _hashCode;
}

// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(SObject.class);

static {
typeDesc.setXmlType(new javax.xml.namespace.QName("urn:sobject.enterprise.soap.sforce.com", "sObject"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("fieldsToNull");
elemField.setXmlName(new javax.xml.namespace.QName("urn:sobject.enterprise.soap.sforce.com", "fieldsToNull"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("id");
elemField.setXmlName(new javax.xml.namespace.QName("urn:sobject.enterprise.soap.sforce.com", "Id"));
elemField.setXmlType(new javax.xml.namespace.QName("urn:enterprise.soap.sforce.com", "ID"));
elemField.setMinOccurs(0);
typeDesc.addFieldDesc(elemField);
}

/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}

/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}

/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}

}

thanks again