1,JWS
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.crc.util.ConfigPropertiesUtil;
import com.sun.org.apache.xml.internal.security.utils.Base64;
public class CASignUtil
{
private static Log log = LogFactory.getLog(CASignUtil.class);
private static final String namespace = "http://signservice.itrus.com/";
public static List<String> getSignInfo(String inPlaintext) throws UnsupportedEncodingException, MalformedURLException
{
log.info("CA start");
List<String> outList = new ArrayList<String>();
String username = ConfigPropertiesUtil.getValueByKey("sign.username");
String password = ConfigPropertiesUtil.getValueByKey("sign.password");
URL webserviceURL = new URL(ConfigPropertiesUtil.getValueByKey("sign.webserviceURL"));
QName serviceQName = new QName(namespace, "ICASignService");
Service service = Service.create(webserviceURL, serviceQName);
TmsICASignDelegate signDelegate = service.getPort(new QName(namespace, "ICASignPort"), TmsICASignDelegate.class);
if(signDelegate.isKeyStoreExist())
{
signDelegate.checkPassWord(password);
String signCertSN = signDelegate.getSignCertificateSerialnumber(username);
outList.add(signCertSN);
System.out.println("Certificate[".concat(username).concat("] SerialNumber:".concat(signCertSN)));
byte[] signData = signDelegate.sign(inPlaintext.getBytes("UTF-8"), username);
String signString = Base64.encode(signData);
outList.add(signString);
System.out.println("s---->" + signString);
}
else
{
log.info("CA: Service can not find the keystore for using.");
}
log.info("CA end");
return outList;
}
}
<service name="ICASignService">
<port binding="tns:ICASignPortBinding" name="ICASignPort">
<soap:address location="http://10.0.63.155:8088/signportal/ICASignPort"/>
</port>
</service>
2,AXIS2
Object[] args = new Object[3];
args[0] = inPlaintextBase64;
args[1] = signInfo.get(1);
args[2] = signInfo.get(0);
Object[] tmsResult = this.sendTMSWebService(configBean.getMcUrl(), "impbill", args);
public Object[] sendTMSWebService(String webServiceURl, String method, Object[] args) throws AxisFault
{
RPCServiceClient client = new RPCServiceClient();
Options options = client.getOptions();
EndpointReference epr = new EndpointReference(webServiceURl);
options.setTo(epr);
options.setTimeOutInMilliSeconds(10 * 60 * 1000);
QName qname = new QName(tmsNameSpace, method);
Object[] result = client.invokeBlocking(qname, args, new Class[]{String.class, String.class, String.class});
return result;
}
<wsdl:service name="ImplHrWSService">
<wsdl:port binding="intf:ImplHrWSSoapBinding" name="ImplHrWS">
<wsdlsoap:address location="http://10.0.63.29:9080/axis/services/ImplHrWS"/>
</wsdl:port>
</wsdl:service>