Re: Sending custom Java objects as parameters to a web service

2011-07-24 Thread Louis Amstutz
Not sure if attaching files works for this mailing list so I'm posting
everything in the email.  My service uses https so TCPmon won't work.  I
tried connecting via http instead and got an exception that said the
expected transport is https, probably because I'm using rampart.  Don't
really want to get into fixing that now since my service is always going to
use https anyway.  I am using Axis2 1.5.5.

Here is the client code that makes the request (I'm not including the
generated stub)

CashcardserviceStub.
Transaction tr = new CashcardserviceStub.Transaction();
tr.setAmount(1000);
tr.setOtherAcct(1004);
tr.setDate(System.currentTimeMillis());
tr.setPending(true);
tr.setTransID(1);
SyncTransaction request4 = new CashcardserviceStub.SyncTransaction();
request4.setT(tr);
stub.syncTransaction(request4);

Here is the server code (note that the syncTransaction method is empty for
now, since it's not even getting to that point.  If I put a break point in
the method it never reaches it)

package cashcard.server;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Logger;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.rampart.RampartMessageData;

import cashcard.data.*;

public class CashcardServer {
private static String logfile =
"C:\\Java\\apache-tomcat-7.0.14\\logs\\cashcard.log";
private static Logger logger = Logger.getLogger("cashcard.server");
private FileHandler fh;

private SQLInterface si;

public CashcardServer() {
si = new SQLInterface();
try {
fh = new FileHandler(logfile, true);
logger.addHandler(fh);
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

public Account getAccount(int accountNo) throws AxisFault {
try {
si.connect();
return si.getAccount(accountNo);
} catch (Exception e) {
logger.severe(e.getMessage());
e.printStackTrace();
throw new AxisFault("Error getting account: " + e.getMessage());
}
finally {si.disconnect();}
}

public Transaction[] getAccountTransactions(int accountNo) throws
AxisFault {
try {
si.connect();
return si.getAccountTransactions(accountNo);
} catch (Exception e) {
logger.severe(e.getMessage());
e.printStackTrace();
throw new AxisFault("Error getting transactions: " +
e.getMessage());
}
finally {si.disconnect();}
}

public AccountNameMap getAccountNames(int[] accountNums) throws
AxisFault {
try {
si.connect();
AccountNameMap accountNames = si.getAccountNames(accountNums);
return accountNames;
} catch (Exception e) {
logger.severe(e.getMessage());
e.printStackTrace();
throw new AxisFault("Error getting account: " + e.getMessage());
}
finally {si.disconnect();}
}

public void doCardTransaction(int amount) throws AxisFault {
try {
int accountNo = getCurrentAccountNum();
si.connect();
si.doCardTransaction(accountNo, amount);
} catch (Exception e) {
logger.severe(e.getMessage());
e.printStackTrace();
throw new AxisFault("Error getting account: " + e.getMessage());
}
finally {si.disconnect();}
}

//public void syncTransaction(int transID, int otherAccountNo, int
amount, long date, boolean isPending) throws AxisFault {
//System.out.println("syncing");
////Transaction[] transactions = new Transaction[]{};
//try {
//si.connect();
//int accountNo = getCurrentAccountNum();
//si.addPendingTransaction(accountNo, transID, otherAccountNo,
amount, date, isPending);
//} catch (Exception e) {
//logger.severe(e.getMessage());
//throw new AxisFault("Error getting account: " +
e.getMessage());
//}
//finally {si.disconnect();}
//}

public void syncTransaction(Transaction t) {

}

private int getCurrentAccountNum() throws AxisFault {
MessageContext msgContext =
MessageContext.getCurrentMessageContext();
String accountNoString =
(String)msgContext.getProperty(RampartMessageData.USERNAME);

try {return Integer.valueOf(accountNoString);}
catch (NumberFormatException e) {throw new AxisFault("Invalid
account No");}
}


}

Here is my services.xml.  I've read that i don't need to declare every
method here, since Axis2 is supposed to automatically make every public
method from the service available, but this doesn't work for me.  They only
work if I declare the operations here.



cashcard.server.CashcardServer







 

Axis2 SOAP Monitor on OutFlow to a foreign server

2011-07-24 Thread Jose Marin

Hello Dear Users,

Does anyone out there know how setup Axis2 soapmonitor so that I can 
view the envelopes being sent by my client to a server not under my control?


I am passing my client constructor a local axis2 configuration context 
(repository and axis2 config) but the endpoint is an address out there 
in the world. I have minimal (if any) error messages coming back,and all 
of them proprietary (can't be Googled). I can't see the outgoing soap 
envelopes, only the body I'm creating from org.apache.axiom.om (via 
System.out). I have verified this is correct so it must be the envelope 
is wrong. Or at least I could verify if I could see it as I assemble it.


Should I be passing the client an axis2 repository that is currently 
being served to do this? Right now I'm passing it a repository that is 
not being served but is deep in the file system. I have tried loading a 
context that is being used by a set of services I'm serving online; I 
can use the soapmonitor there just fine to intercept calls to those 
servers, I just couldn't figure out how to route my client to go though 
it before hitting the web.


I'm also using ssl (it's a requirement). Which is why I'm not using 
tcpmon instead.


Thank you everyone and anyone who participates.

Jose Marin


-
To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org
For additional commands, e-mail: java-user-h...@axis.apache.org