本文整理汇总了Java中javax.xml.soap.SOAPException类的典型用法代码示例。如果您正苦于以下问题:Java SOAPException类的具体用法?Java SOAPException怎么用?Java SOAPException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SOAPException类属于javax.xml.soap包,在下文中一共展示了SOAPException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttachmentsInfo
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* Returns a string containing info about all the SOAP attachments.
*
* @param soapMessage SOAP message
* @return String containing attachments info
*/
public static String getAttachmentsInfo(SOAPMessage soapMessage) {
try {
int numOfAttachments = soapMessage.countAttachments();
Iterator attachments = soapMessage.getAttachments();
StringBuilder buf = new StringBuilder("Number of attachments: ");
buf.append(numOfAttachments);
int count = 1;
while (attachments.hasNext()) {
AttachmentPart attachment = (AttachmentPart) attachments.next();
buf.append(" | #").append(count);
buf.append(" | Content Location: ").append(attachment.getContentLocation());
buf.append(" | Content Id: ").append(attachment.getContentId());
buf.append(" | Content Size: ").append(attachment.getSize());
buf.append(" | Content Type: ").append(attachment.getContentType());
count++;
}
return buf.toString();
} catch (SOAPException e) {
LOGGER.error(e.getMessage(), e);
return "";
}
}
示例2: createMUSOAPFaultMessage
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* This should be used only in ServerMUPipe
*
* @param notUnderstoodHeaders
* @return Message representing a SOAPFault
* In SOAP 1.1, notUnderstoodHeaders are added in the fault Detail
* in SOAP 1.2, notUnderstoodHeaders are added as the SOAP Headers
*/
final Message createMUSOAPFaultMessage(Set<QName> notUnderstoodHeaders) {
try {
String faultString = MUST_UNDERSTAND_FAULT_MESSAGE_STRING;
if (soapVersion == SOAP_11) {
faultString = "MustUnderstand headers:" + notUnderstoodHeaders + " are not understood";
}
Message muFaultMessage = SOAPFaultBuilder.createSOAPFaultMessage(
soapVersion,faultString,soapVersion.faultCodeMustUnderstand);
if (soapVersion == SOAP_12) {
addHeader(muFaultMessage, notUnderstoodHeaders);
}
return muFaultMessage;
} catch (SOAPException e) {
throw new WebServiceException(e);
}
}
示例3: addNode
import javax.xml.soap.SOAPException; //导入依赖的package包/类
protected void addNode(org.w3c.dom.Node newElement) throws SOAPException {
insertBefore(soapDocument.getDomNode(newElement), null);
if (getOwnerDocument() instanceof DocumentFragment)
return;
if (newElement instanceof ElementImpl) {
ElementImpl element = (ElementImpl) newElement;
QName elementName = element.getElementQName();
if (!"".equals(elementName.getNamespaceURI())) {
element.ensureNamespaceIsDeclared(
elementName.getPrefix(), elementName.getNamespaceURI());
}
}
}
示例4: test1
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* Client list with 2 members (MEMBER, SUBSYSTEM)
*
* @throws XRd4JException
* @throws SOAPException
*/
public void test1() throws XRd4JException, SOAPException {
String soapString = "<?xml version=\"1.0\"?><xrd:clientList xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\" xmlns:id=\"http://x-road.eu/xsd/identifiers\"><xrd:member><xrd:id id:objectType=\"MEMBER\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>12345</id:memberCode></xrd:id><xrd:name>Test org</xrd:name></xrd:member><xrd:member><xrd:id id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI-DEV</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>54321</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:id><xrd:name>Another org</xrd:name></xrd:member></xrd:clientList>";
List<ConsumerMember> list = new ListClientsResponseDeserializer().deserializeConsumerList(soapString);
assertEquals("FI", list.get(0).getXRoadInstance());
assertEquals("GOV", list.get(0).getMemberClass());
assertEquals("12345", list.get(0).getMemberCode());
assertEquals(null, list.get(0).getSubsystemCode());
assertEquals(ObjectType.MEMBER, list.get(0).getObjectType());
assertEquals("FI-DEV", list.get(1).getXRoadInstance());
assertEquals("COM", list.get(1).getMemberClass());
assertEquals("54321", list.get(1).getMemberCode());
assertEquals("subsystem", list.get(1).getSubsystemCode());
assertEquals(ObjectType.SUBSYSTEM, list.get(1).getObjectType());
}
示例5: addSoapHeader
import javax.xml.soap.SOAPException; //导入依赖的package包/类
protected void addSoapHeader(SOAPMessage soapMessage) throws SOAPException, NoSuchAlgorithmException {
onvifDevice.createNonce();
String encrypedPassword = onvifDevice.getEncryptedPassword();
if (encrypedPassword != null && onvifDevice.getUsername() != null) {
SOAPPart sp = soapMessage.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPHeader header = soapMessage.getSOAPHeader();
se.addNamespaceDeclaration("wsse",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
se.addNamespaceDeclaration("wsu",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
SOAPElement securityElem = header.addChildElement("Security", "wsse");
// securityElem.setAttribute("SOAP-ENV:mustUnderstand", "1");
SOAPElement usernameTokenElem = securityElem.addChildElement("UsernameToken", "wsse");
SOAPElement usernameElem = usernameTokenElem.addChildElement("Username", "wsse");
usernameElem.setTextContent(onvifDevice.getUsername());
SOAPElement passwordElem = usernameTokenElem.addChildElement("Password", "wsse");
passwordElem.setAttribute("Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
passwordElem.setTextContent(encrypedPassword);
SOAPElement nonceElem = usernameTokenElem.addChildElement("Nonce", "wsse");
nonceElem.setAttribute("EncodingType",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
nonceElem.setTextContent(onvifDevice.getEncryptedNonce());
SOAPElement createdElem = usernameTokenElem.addChildElement("Created", "wsu");
createdElem.setTextContent(onvifDevice.getLastUTCTime());
}
}
示例6: test7
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* Subsystem level service call. Use namespace prefix in request's and
* response's child elements.
* @throws XRd4JException
* @throws SOAPException
*/
public void test7() throws XRd4JException, SOAPException {
String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>7.5</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><ns1:request><ns1:data>Request data</ns1:data></ns1:request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>";
String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>7.5</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandomResponse xmlns:ns1=\"http://consumer.x-road.ee\"><ns1:request><ns1:data>Request data</ns1:data></ns1:request><ns1:response><ns1:data>Response data</ns1:data></ns1:response></ns1:getRandomResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>";
ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem");
ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1");
ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890");
request.setUserId("EE1234567890");
request.setProtocolVersion("7.5");
request.setRequestData("Request data");
request.setSoapMessage(SOAPHelper.toSOAP(requestStr));
request.getProducer().setNamespacePrefix("ns1");
request.getProducer().setNamespaceUrl("http://consumer.x-road.ee");
ServiceResponse<String, String> response = new ServiceResponse<String, String>(request.getConsumer(), request.getProducer(), request.getId());
response.setResponseData("Response data");
ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl2();
SOAPMessage msg = serializer.serialize(response, request);
assertEquals(correctResponse, SOAPHelper.toString(msg));
}
示例7: test1WithoutWrappers
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* Subsystem level service call. No NS prefix.
*
* @throws XRd4JException
* @throws SOAPException
*/
public void test1WithoutWrappers() throws XRd4JException, SOAPException {
String correctRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><getRandom xmlns=\"http://consumer.x-road.ee\"><data>1234567890</data></getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>";
ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem");
ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1");
producer.setNamespacePrefix("");
producer.setNamespaceUrl("http://consumer.x-road.ee");
ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890");
request.setUserId("EE1234567890");
request.setRequestData("1234567890");
request.setProcessingWrappers(false);
ServiceRequestSerializer serializer = new TestRequestSerializer();
SOAPMessage msg = serializer.serialize(request);
assertEquals(correctRequest, SOAPHelper.toString(msg));
}
示例8: test11
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* Subsystem level service call. No NS on request. NS prefix on response.
* Request element with no children
* @throws XRd4JException
* @throws SOAPException
*/
public void test11() throws XRd4JException, SOAPException {
String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><request></request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>";
String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><xxprod:getRandomResponse xmlns:xxprod=\"http://foobar.x-road.ee/producer\"><xxprod:request/><xxprod:response><xxprod:data>Response data</xxprod:data></xxprod:response></xxprod:getRandomResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>";
ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem");
ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1");
ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890");
request.setUserId("EE1234567890");
request.setRequestData("Request data");
request.setSoapMessage(SOAPHelper.toSOAP(requestStr));
request.getProducer().setNamespacePrefix("xxprod");
request.getProducer().setNamespaceUrl("http://foobar.x-road.ee/producer");
ServiceResponse<String, String> response = new ServiceResponse<String, String>(request.getConsumer(), request.getProducer(), request.getId());
response.setResponseData("Response data");
ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl();
SOAPMessage msg = serializer.serialize(response, request);
assertEquals(correctResponse, SOAPHelper.toString(msg));
}
示例9: createEnvelopeFromSource
import javax.xml.soap.SOAPException; //导入依赖的package包/类
@Override
protected Envelope createEnvelopeFromSource() throws SOAPException {
// Record the presence of xml declaration before the envelope gets
// created.
XMLDeclarationParser parser = lookForXmlDecl();
Source tmp = source;
source = null;
EnvelopeImpl envelope =
(EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);
if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
}
if (parser != null && !omitXmlDecl) {
envelope.setOmitXmlDecl("no");
envelope.setXmlDecl(parser.getXmlDeclaration());
envelope.setCharsetEncoding(parser.getEncoding());
}
return envelope;
}
示例10: checkIfStandardFaultCode
import javax.xml.soap.SOAPException; //导入依赖的package包/类
@Override
protected void checkIfStandardFaultCode(String faultCode, String uri)
throws SOAPException {
QName qname = new QName(uri, faultCode);
if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) ||
SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) ||
SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) ||
SOAPConstants.SOAP_SENDER_FAULT.equals(qname) ||
SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname))
return;
log.log(
Level.SEVERE,
"SAAJ0435.ver1_2.code.not.standard",
qname);
throw new SOAPExceptionImpl(qname + " is not a standard Code value");
}
示例11: test9
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* Subsystem level service call. Producer namespace and prefix already set
* by the serializer implementation.
*
* @throws XRd4JException
* @throws SOAPException
*/
public void test9() throws XRd4JException, SOAPException {
String correctRequest = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><ns1:request><ns1:data>1234567890</ns1:data></ns1:request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>";
ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem");
ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1");
producer.setNamespacePrefix("ns1");
producer.setNamespaceUrl("http://consumer.x-road.ee");
ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890");
request.setUserId("EE1234567890");
request.setRequestData("1234567890");
ServiceRequestSerializer serializer = new TestRequestSerializer1();
SOAPMessage msg = serializer.serialize(request);
assertEquals(correctRequest, SOAPHelper.toString(msg));
}
示例12: testSOAPFault3
import javax.xml.soap.SOAPException; //导入依赖的package包/类
/**
* SOAP Fault with detail null.
* @throws XRd4JException
* @throws SOAPException
*/
public void testSOAPFault3() throws XRd4JException, SOAPException {
String requestStr = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:id=\"http://x-road.eu/xsd/identifiers\" xmlns:xrd=\"http://x-road.eu/xsd/xroad.xsd\"><SOAP-ENV:Header><xrd:client id:objectType=\"SUBSYSTEM\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>GOV</id:memberClass><id:memberCode>MEMBER1</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode></xrd:client><xrd:service id:objectType=\"SERVICE\"><id:xRoadInstance>FI</id:xRoadInstance><id:memberClass>COM</id:memberClass><id:memberCode>MEMBER2</id:memberCode><id:subsystemCode>subsystem</id:subsystemCode><id:serviceCode>getRandom</id:serviceCode><id:serviceVersion>v1</id:serviceVersion></xrd:service><xrd:userId>EE1234567890</xrd:userId><xrd:id>1234567890</xrd:id><xrd:protocolVersion>4.0</xrd:protocolVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getRandom xmlns:ns1=\"http://consumer.x-road.ee\"><request><data>Request data</data></request></ns1:getRandom></SOAP-ENV:Body></SOAP-ENV:Envelope>";
String correctResponse = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Header/><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Fault code</faultcode><faultstring>Fault string</faultstring><faultactor>Fault actor</faultactor></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>";
ConsumerMember consumer = new ConsumerMember("FI", "GOV", "MEMBER1", "subsystem");
ProducerMember producer = new ProducerMember("FI", "COM", "MEMBER2", "subsystem", "getRandom", "v1");
ServiceRequest<String> request = new ServiceRequest<String>(consumer, producer, "1234567890");
request.setUserId("EE1234567890");
request.setRequestData("Request data");
request.setSoapMessage(SOAPHelper.toSOAP(requestStr));
request.getProducer().setNamespacePrefix("xxprod");
request.getProducer().setNamespaceUrl("http://foobar.x-road.ee/producer");
ServiceResponse<String, String> response = new ServiceResponse<String, String>();
response.setResponseData("Response data");
ErrorMessage errorMsg = new ErrorMessage("Fault code", "Fault string", "Fault actor", null);
response.setErrorMessage(errorMsg);
ServiceResponseSerializer serializer = new ServiceResponseSerializerImpl();
SOAPMessage msg = serializer.serialize(response, request);
assertEquals(correctResponse, SOAPHelper.toString(msg));
}
示例13: getXmlPayload
import javax.xml.soap.SOAPException; //导入依赖的package包/类
private String getXmlPayload(SOAPMessage rawSoapResponse) throws IOException, SOAPException {
String prefix = rawSoapResponse.getSOAPPart().getEnvelope().getPrefix();
String rawResponse = convertToString(rawSoapResponse);
String xmlMessage = "";
String beginSoapTag = "<" + prefix + ":Envelope";
String endSoapTag = "</" + prefix + ":Envelope>";
int start = rawResponse.indexOf(beginSoapTag);
int end = rawResponse.lastIndexOf(endSoapTag) + prefix.length() + LENGTH_XML_ENCLOSING_TAG;
if (start >= 0 || end > 0) {
xmlMessage = rawResponse.substring(start, end);
LOGGER.debug("xmlMessage = " + xmlMessage);
} else {
throw new IllegalArgumentException("Can't parse soap message " + rawResponse);
}
return xmlMessage;
}
示例14: setEncodingStyle
import javax.xml.soap.SOAPException; //导入依赖的package包/类
@Override
public void setEncodingStyle(String encodingStyle) throws SOAPException {
if (!"".equals(encodingStyle)) {
try {
new URI(encodingStyle);
} catch (URISyntaxException m) {
log.log(
Level.SEVERE,
"SAAJ0105.impl.encoding.style.mustbe.valid.URI",
new String[] { encodingStyle });
throw new IllegalArgumentException(
"Encoding style (" + encodingStyle + ") should be a valid URI");
}
}
encodingStyleAttribute.setValue(encodingStyle);
tryToFindEncodingStyleAttributeName();
}
示例15: writeAttribute
import javax.xml.soap.SOAPException; //导入依赖的package包/类
@Override
public void writeAttribute(final String prefix, final String ns, final String ln, final String value) throws XMLStreamException {
try {
if (ns == null) {
if (prefix == null && xmlns.equals(ln)) {
currentElement.addNamespaceDeclaration("", value);
} else {
currentElement.setAttributeNS("", ln, value);
}
} else {
QName name = (prefix == null) ? new QName(ns, ln) : new QName(ns, ln, prefix);
currentElement.addAttribute(name, value);
}
} catch (SOAPException e) {
throw new XMLStreamException(e);
}
}