本文整理汇总了Java中org.apache.axis.message.SOAPEnvelope类的典型用法代码示例。如果您正苦于以下问题:Java SOAPEnvelope类的具体用法?Java SOAPEnvelope怎么用?Java SOAPEnvelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SOAPEnvelope类属于org.apache.axis.message包,在下文中一共展示了SOAPEnvelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEmptyPasswordProcessing
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test that processes a UserNameToken with an empty password
*/
public void testEmptyPasswordProcessing() throws Exception {
InputStream in = new ByteArrayInputStream(EMPTY_PASSWORD_MSG.getBytes());
Message msg = new Message(in);
msg.setMessageContext(msgContext);
SOAPEnvelope utEnvelope = msg.getSOAPEnvelope();
Document doc = utEnvelope.getAsDocument();
if (LOG.isDebugEnabled()) {
LOG.debug("Empty password message: ");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
verify(doc);
}
示例2: testCreateBinarySecurityToken
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* A unit test for creating BinarySecurityTokens
*/
public void testCreateBinarySecurityToken() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
Document doc = unsignedEnvelope.getAsDocument();
WSSConfig.getNewInstance();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
BinarySecurity bst = new BinarySecurity(doc);
bst.setValueType(AP_REQ);
bst.setEncodingType(BASE64_NS);
bst.setToken("12345678".getBytes());
WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
if (LOG.isDebugEnabled()) {
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
assertTrue(AP_REQ.equals(bst.getValueType()));
assertTrue(BASE64_NS.equals(bst.getEncodingType()));
assertTrue(bst.getToken() != null);
}
示例3: testEncryptionSigning
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test that encrypts and signs a WS-Security envelope, then performs
* verification and decryption <p/>
*
* @throws Exception
* Thrown when there is any problem in signing, encryption,
* decryption, or verification
*/
public void testEncryptionSigning() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
WSSecEncrypt encrypt = new WSSecEncrypt();
WSSecSignature sign = new WSSecSignature();
encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
LOG.info("Before Encryption....");
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
Document encryptedSignedDoc = sign.build(encryptedDoc, crypto,
secHeader);
LOG.info("After Encryption....");
verify(encryptedSignedDoc);
}
示例4: testSigningEncryption
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test that signs and then encrypts a WS-Security envelope, then performs
* decryption and verification <p/>
*
* @throws Exception
* Thrown when there is any problem in signing, encryption,
* decryption, or verification
*/
public void testSigningEncryption() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
WSSecEncrypt encrypt = new WSSecEncrypt();
WSSecSignature sign = new WSSecSignature();
encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
LOG.info("Before Encryption....");
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
Document signedDoc = sign.build(doc, crypto, secHeader);
Document encryptedSignedDoc = encrypt.build(signedDoc, crypto, secHeader);
LOG.info("After Encryption....");
verify(encryptedSignedDoc);
}
示例5: testSymmetricSignatureSHA1
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test signing a message body using a symmetric key with EncryptedKeySHA1
*/
public void testSymmetricSignatureSHA1() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
WSSecSignature sign = new WSSecSignature();
sign.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
sign.setSecretKey(keyData);
sign.setSignatureAlgorithm(SignatureMethod.HMAC_SHA1);
Document signedDoc = sign.build(doc, crypto, secHeader);
if (LOG.isDebugEnabled()) {
LOG.debug("Signed symmetric message SHA1:");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
verify(signedDoc);
}
示例6: testNoSOAPNamespacePrefix
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test signing a SOAP message that has no SOAP namespace prefix
*/
public void testNoSOAPNamespacePrefix() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
WSSecSignature sign = new WSSecSignature();
sign.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.setActor("bob");
secHeader.insertSecurityHeader(doc);
Document signedDoc = sign.build(doc, crypto, secHeader);
if (LOG.isDebugEnabled()) {
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
verify(signedDoc);
}
示例7: testSignatureOID
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test signing a SOAP message using a cert with an OID
*/
public void testSignatureOID() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
WSSecSignature sign = new WSSecSignature();
sign.setUserInfo("wss86", "security");
sign.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
Document signedDoc = sign.build(doc, crypto, secHeader);
if (LOG.isDebugEnabled()) {
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
verify(signedDoc);
}
示例8: testEncryptionDecryptionOAEP
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test that encrypt and decrypt a WS-Security envelope.
* This test uses the RSA OAEP algorithm to transport (wrap) the symmetric
* key.
* <p/>
*
* @throws Exception Thrown when there is any problem in signing or verification
*/
public void testEncryptionDecryptionOAEP() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
WSSecEncrypt builder = new WSSecEncrypt();
builder.setUserInfo("wss40");
builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
builder.setKeyEnc(WSConstants.KEYTRANSPORT_RSAOEP);
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
LOG.info("Before Encryption Triple DES/RSA-OAEP....");
Document encryptedDoc = builder.build(doc, crypto, secHeader);
LOG.info("After Encryption Triple DES/RSA-OAEP....");
String outputString =
org.apache.ws.security.util.XMLUtils.PrettyDocumentToString(encryptedDoc);
if (LOG.isDebugEnabled()) {
LOG.debug("Encrypted message, RSA-OAEP keytransport, 3DES:");
LOG.debug(outputString);
}
assertTrue(outputString.indexOf("LogTestService2") == -1 ? true : false);
verify(encryptedDoc, SOAP_BODY);
}
示例9: testEncryptionEncryption
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Test that encrypt and then again encrypts (Super encryption) WS-Security
* envelope and then verifies ist <p/>
*
* @throws Exception
* Thrown when there is any problem in encryption or
* verification
*/
public void testEncryptionEncryption() throws Exception {
SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
WSSecEncrypt encrypt = new WSSecEncrypt();
encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e");
LOG.info("Before Encryption....");
Document doc = unsignedEnvelope.getAsDocument();
WSSecHeader secHeader = new WSSecHeader();
secHeader.insertSecurityHeader(doc);
Document encryptedDoc = encrypt.build(doc, crypto, secHeader);
Document encryptedEncryptedDoc = encrypt.build(encryptedDoc, crypto,
secHeader);
LOG.info("After Encryption....");
verify(encryptedEncryptedDoc);
}
示例10: processMessage
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
public void processMessage(MessageContext msgContext, SOAPEnvelope reqEnv, SOAPEnvelope resEnv, Object obj) throws Exception {
RPCElement body = getBody(reqEnv, msgContext);
OperationDesc operation = getOperationDesc(msgContext, body);
AxisRpcInterceptor interceptor = new AxisRpcInterceptor(operation, msgContext);
SOAPMessage message = msgContext.getMessage();
try {
message.getSOAPPart().getEnvelope();
msgContext.setProperty(org.apache.axis.SOAPPart.ALLOW_FORM_OPTIMIZATION, Boolean.FALSE);
RpcContainer container = (RpcContainer) ejbDeployment.getContainer();
Object[] arguments = {msgContext, interceptor};
Class callInterface = ejbDeployment.getServiceEndpointInterface();
Object result = container.invoke(ejbDeployment.getDeploymentID(), InterfaceType.SERVICE_ENDPOINT, callInterface, operation.getMethod(), arguments, null);
interceptor.createResult(result);
} catch (ApplicationException e) {
interceptor.createExceptionResult(e.getCause());
} catch (Throwable throwable) {
throw new AxisFault("Web Service EJB Invocation failed: method " + operation.getMethod(), throwable);
}
}
示例11: createResult
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
public void createResult(Object object) {
messageContext.setPastPivot(true);
try {
Message requestMessage = messageContext.getRequestMessage();
SOAPEnvelope requestEnvelope = requestMessage.getSOAPEnvelope();
RPCElement requestBody = getBody(requestEnvelope, messageContext);
Message responseMessage = messageContext.getResponseMessage();
SOAPEnvelope responseEnvelope = responseMessage.getSOAPEnvelope();
ServiceDesc serviceDescription = messageContext.getService().getServiceDescription();
RPCElement responseBody = createResponseBody(requestBody, messageContext, operation, serviceDescription, object, responseEnvelope, getInOutParams());
responseEnvelope.removeBody();
responseEnvelope.addBodyElement(responseBody);
} catch (Exception e) {
throw new ServerRuntimeException("Failed while creating response message body", e);
}
}
示例12: main
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
try {
Options opts = new Options(args);
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(opts.getURL()));
SOAPEnvelope env = new SOAPEnvelope();
SOAPBodyElement sbe = new SOAPBodyElement(XMLUtils.StringToElement("http://localhost:8080/LogTestService", "testMethod", ""));
env.addBodyElement(sbe);
env = new SignedSOAPEnvelope(env, "http://xml-security");
System.out.println("\n============= Request ==============");
XMLUtils.PrettyElementToStream(env.getAsDOM(), System.out);
call.invoke(env);
MessageContext mc = call.getMessageContext();
System.out.println("\n============= Response ==============");
XMLUtils.PrettyElementToStream(mc.getResponseMessage().getSOAPEnvelope().getAsDOM(), System.out);
}
catch (Exception e) {
e.printStackTrace();
}
}
示例13: getSOAPEnvelopeAsDocument
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
private Document getSOAPEnvelopeAsDocument(SOAPEnvelope env, MessageContext msgContext)
throws Exception {
StringWriter writer = new StringWriter();
SerializationContext serializeContext = new SerializationContext(writer, msgContext);
env.output(serializeContext);
writer.close();
Reader reader = new StringReader(writer.getBuffer().toString());
Document doc = XMLUtils.newDocument(new InputSource(reader));
if (doc == null)
throw new Exception(
Messages.getMessage("noDoc00", writer.getBuffer().toString()));
return doc;
}
示例14: doTest
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
/**
* Send a hardcoded message to the server, and print the response.
*
* @param args the command line arguments (mainly for specifying URL)
* @param op an optional service argument, which will be used for
* specifying the transport-level service
*/
public static String doTest (String args[], String op) throws Exception {
Options opts = new Options( args );
String url = opts.getURL();
String action = "EchoService" ;
if (op != null) action = op;
args = opts.getRemainingArgs();
if ( args != null ) action = args[0];
InputStream input = new ByteArrayInputStream(msg.getBytes());
Service service = new Service();
Call call = (Call) service.createCall();
SOAPEnvelope env = new SOAPEnvelope(input);
call.setTargetEndpointAddress( new URL(url) );
if (action != null) {
call.setUseSOAPAction( true );
call.setSOAPActionURI( action );
}
System.out.println( "Request:\n" + msg );
env = call.invoke( env );
System.out.println( "Response:\n" + env.toString() );
return( env.toString() );
}
示例15: invoke
import org.apache.axis.message.SOAPEnvelope; //导入依赖的package包/类
@Override
public void invoke(MessageContext msgContext) throws AxisFault {
final SOAPEnvelope envelope = msgContext.getResponseMessage().getSOAPEnvelope();
for (SOAPHeaderElement she : envelope.getHeaders()) {
she.setProcessed(true);
}
}