NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
smcneese
Joined: 29 May 2009 Posts: 11
|
Posted: Fri Oct 29, 2010 2:17 am Post subject: Calling Webservice with Output Parameters |
|
|
I have been trying to call a web service I created that has 1 output parameter of type string and also has an integer return code. When I create the web service client and generate the stubs, I get a class for the returnresult of the web method. This class has methods to get the output parameter string result and the returncode value. The call to the web service is successful, but the returncode is null and the output parameter value returned by the class method is null. I can successfully call this same web service from VBA or a win32 form and it works just fine.
THe only type of web service methods I have been able to call inside my j2me application are ones that return a single value. So for instance, I could convert this web method to return a string instead of the returncode int and it works fine. The problem is I need the return code in addition to the output parameter string which is the xml result of the query.
What am I doing wrong? Is there a bug in the service stubs that are generated for web methods that return values via output parameters? Is there anything special I need to do to return the result from this call to the an instance of the result class that was generated?
Any insight would be greatly appreciated. I have been pulling out my hair for the last couple of days on this.
Thank you,
Steve |
|
| Back to top |
|
 |
smcneese
Joined: 29 May 2009 Posts: 11
|
Posted: Mon Nov 01, 2010 12:51 pm Post subject: Anyone? |
|
|
Has anyone called .net webservice from J2ME that has an output parameter? Please help.
Response object:
| Code: |
package services;
import javax.xml.namespace.QName;
import org.netbeans.microedition.databinding.DataSet;
import org.netbeans.microedition.databinding.DataBindingException;
public class GetTodaysEventsResponse implements DataSet {
private int getTodaysEventsResult;
public void setGetTodaysEventsResult( int getTodaysEventsResult ) {
this.getTodaysEventsResult = getTodaysEventsResult;
}
public int getGetTodaysEventsResult() {
return getTodaysEventsResult;
}
private String events;
public void setEvents( String events ) {
this.events = events;
}
public String getEvents() {
return events;
}
public Class getType(String dataItemName) {
if( "getTodaysEventsResult".equals(dataItemName)) {
return Integer.class;
}
if( "events".equals(dataItemName)) {
return String.class;
}
throw new IllegalArgumentException( "Invalid data item name " + dataItemName );
}
public Object getValue(String dataItemName) {
if( "getTodaysEventsResult".equals(dataItemName)) {
return new Integer(getTodaysEventsResult);
}
if( "events".equals(dataItemName)) {
return events;
}
throw new IllegalArgumentException( "Invalid data item name " + dataItemName );
}
public void setValue(String dataItemName, Object value) throws DataBindingException {
if( "getTodaysEventsResult".equals(dataItemName)) {
getTodaysEventsResult = ((Integer ) value).intValue();
}
if( "events".equals(dataItemName)) {
events = (String ) value;
}
}
public void setAsString(String dataItemName, String value) throws DataBindingException {
if( "getTodaysEventsResult".equals(dataItemName)) {
getTodaysEventsResult = Integer.parseInt(value);
}
if( "events".equals(dataItemName)) {
events = value;
}
}
public boolean isReadOnly(String dataItemName) {
return false;
}
}
|
Stub
| Code: |
package services;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.microedition.xml.rpc.Operation;
import javax.microedition.xml.rpc.Type;
import javax.microedition.xml.rpc.ComplexType;
import javax.microedition.xml.rpc.Element;
public class Service_Stub implements Service, javax.xml.rpc.Stub {
private String[] _propertyNames;
private Object[] _propertyValues;
public Service_Stub() {
_propertyNames = new String[] { ENDPOINT_ADDRESS_PROPERTY };
_propertyValues = new Object[] { "http://www.somedomain.com/fpevws/Service.asmx" };
}
public void _setProperty( String name, Object value ) {
int size = _propertyNames.length;
for (int i = 0; i < size; ++i) {
if( _propertyNames[i].equals( name )) {
_propertyValues[i] = value;
return;
}
}
String[] newPropNames = new String[size + 1];
System.arraycopy(_propertyNames, 0, newPropNames, 0, size);
_propertyNames = newPropNames;
Object[] newPropValues = new Object[size + 1];
System.arraycopy(_propertyValues, 0, newPropValues, 0, size);
_propertyValues = newPropValues;
_propertyNames[size] = name;
_propertyValues[size] = value;
}
public Object _getProperty(String name) {
for (int i = 0; i < _propertyNames.length; ++i) {
if (_propertyNames[i].equals(name)) {
return _propertyValues[i];
}
}
if (ENDPOINT_ADDRESS_PROPERTY.equals(name) || USERNAME_PROPERTY.equals(name) || PASSWORD_PROPERTY.equals(name)) {
return null;
}
if (SESSION_MAINTAIN_PROPERTY.equals(name)) {
return new Boolean(false);
}
throw new JAXRPCException("Stub does not recognize property: " + name);
}
protected void _prepOperation(Operation op) {
for (int i = 0; i < _propertyNames.length; ++i) {
op.setProperty(_propertyNames[i], _propertyValues[i].toString());
}
}
public int AddUpdateEventValetUsers(int AccessValetID, String FirstName, String LastName, String Terminated) throws java.rmi.RemoteException {
Object inputObject[] = new Object[] {
new Integer(AccessValetID),
FirstName,
LastName,
Terminated
};
Operation op = Operation.newInstance( _qname_operation_AddUpdateEventValetUsers, _type_AddUpdateEventValetUsers, _type_AddUpdateEventValetUsersResponse );
_prepOperation( op );
op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "http://tempuri.org/AddUpdateEventValetUsers" );
Object resultObj;
try {
resultObj = op.invoke( inputObject );
} catch( JAXRPCException e ) {
Throwable cause = e.getLinkedCause();
if( cause instanceof java.rmi.RemoteException ) {
throw (java.rmi.RemoteException) cause;
}
throw e;
}
return ((Integer )((Object[])resultObj)[0]).intValue();
}
public GetTodaysEventsResponse GetTodaysEvents() throws java.rmi.RemoteException {
Object inputObject[] = new Object[] {
};
Operation op = Operation.newInstance( _qname_operation_GetTodaysEvents, _type_GetTodaysEvents, _type_GetTodaysEventsResponse );
_prepOperation( op );
op.setProperty( Operation.SOAPACTION_URI_PROPERTY, "http://tempuri.org/GetTodaysEvents" );
Object resultObj;
try {
resultObj = op.invoke( inputObject );
} catch( JAXRPCException e ) {
Throwable cause = e.getLinkedCause();
if( cause instanceof java.rmi.RemoteException ) {
throw (java.rmi.RemoteException) cause;
}
throw e;
}
System.out.println((Object[])((Object[]) resultObj)[0]);
return GetTodaysEventsResponse_fromObject((Object[])(((Object[]) resultObj)[0]));
}
private static GetTodaysEventsResponse GetTodaysEventsResponse_fromObject( Object obj[] ) {
if(obj == null) return null;
GetTodaysEventsResponse result = new GetTodaysEventsResponse();
result.setGetTodaysEventsResult(((Integer )obj[0]).intValue());
result.setEvents((String )obj[1]);
return result;
}
protected static final QName _qname_operation_AddUpdateEventValetUsers = new QName( "http://tempuri.org/", "AddUpdateEventValetUsers" );
protected static final QName _qname_operation_GetTodaysEvents = new QName( "http://tempuri.org/", "GetTodaysEvents" );
protected static final QName _qname_GetTodaysEventsResponse = new QName( "http://tempuri.org/", "GetTodaysEventsResponse" );
protected static final QName _qname_AddUpdateEventValetUsers = new QName( "http://tempuri.org/", "AddUpdateEventValetUsers" );
protected static final QName _qname_AddUpdateEventValetUsersResponse = new QName( "http://tempuri.org/", "AddUpdateEventValetUsersResponse" );
protected static final QName _qname_GetTodaysEvents = new QName( "http://tempuri.org/", "GetTodaysEvents" );
protected static final Element _type_GetTodaysEventsResponse;
protected static final Element _type_GetTodaysEvents;
protected static final Element _type_AddUpdateEventValetUsers;
protected static final Element _type_AddUpdateEventValetUsersResponse;
static {
_type_GetTodaysEventsResponse = new Element( _qname_GetTodaysEventsResponse, _complexType( new Element[] {
new Element( new QName( "http://tempuri.org/", "GetTodaysEventsResult" ), Type.INT ),
new Element( new QName( "http://tempuri.org/", "Events" ), Type.STRING, 0, 1, false )}), 1, 1, false );
_type_AddUpdateEventValetUsers = new Element( _qname_AddUpdateEventValetUsers, _complexType( new Element[] {
new Element( new QName( "http://tempuri.org/", "AccessValetID" ), Type.INT ),
new Element( new QName( "http://tempuri.org/", "FirstName" ), Type.STRING, 0, 1, false ),
new Element( new QName( "http://tempuri.org/", "LastName" ), Type.STRING, 0, 1, false ),
new Element( new QName( "http://tempuri.org/", "Terminated" ), Type.STRING, 0, 1, false )}), 1, 1, false );
_type_GetTodaysEvents = new Element( _qname_GetTodaysEvents, _complexType( new Element[] {
}), 1, 1, false );
_type_AddUpdateEventValetUsersResponse = new Element( _qname_AddUpdateEventValetUsersResponse, _complexType( new Element[] {
new Element( new QName( "http://tempuri.org/", "AddUpdateEventValetUsersResult" ), Type.INT )}), 1, 1, false );
}
private static ComplexType _complexType( Element[] elements ) {
ComplexType result = new ComplexType();
result.elements = elements;
return result;
}
}
|
Again, the AddUpdateEventValetUsers works fine or any webmethod I write that does not have any output parameters - just a return code. If I include an output parameter in the webmethod, I can never get a good result when calling from J2ME/Netbeans. If I call the web method from VBA or C# it works fine.
Thank you,
Steve |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|