本文整理汇总了Java中javax.xml.soap.SOAPFault.getFaultCode方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPFault.getFaultCode方法的具体用法?Java SOAPFault.getFaultCode怎么用?Java SOAPFault.getFaultCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPFault
的用法示例。
在下文中一共展示了SOAPFault.getFaultCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callWebService
import javax.xml.soap.SOAPFault; //导入方法依赖的package包/类
public String callWebService(String msisdn) throws SOAPException, IOException, XWSSecurityException, GetTermalIccidException {
SOAPMessage request = createTerminalRequest(msisdn);
request = secureMessage(request);
// TODO
logger.info("Get Terminals by msisdn Request: ");
request.writeTo(System.out);
System.out.println("");
SOAPConnection connection = connectionFactory.createConnection();
SOAPMessage response = connection.call(request, url);
// TODO
logger.info("Get Terminals by msisdn Response: ");
response.writeTo(System.out);
System.out.println("");
if (!response.getSOAPBody().hasFault()) {
return writeTerminalResponse(response);
} else {
SOAPFault fault = response.getSOAPBody().getFault();
logger.error("Received SOAP Fault");
logger.error("SOAP Fault Code :" + fault.getFaultCode());
logger.error("SOAP Fault String :" + fault.getFaultString());
throw new GetTermalIccidException(fault.getFaultCode() + "," + fault.getFaultString());
}
}
示例2: testFaultCodeWithPrefix1
import javax.xml.soap.SOAPFault; //导入方法依赖的package包/类
@Test
public void testFaultCodeWithPrefix1() throws Exception {
MessageFactory fac = MessageFactory.newInstance();
SOAPMessage soapMessage = fac.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPFault sf = body.addFault();
String prefix = "wso2";
sf.setFaultCode(prefix + ":Server");
String result = sf.getFaultCode();
assertNotNull(result);
assertEquals(prefix + ":Server", result);
}
示例3: testFaultCodeWithPrefix2
import javax.xml.soap.SOAPFault; //导入方法依赖的package包/类
@Test
public void testFaultCodeWithPrefix2() throws Exception {
MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage soapMessage = fac.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPFault sf = body.addFault();
String prefix = "wso2";
sf.setFaultCode(prefix + ":Server");
String result = sf.getFaultCode();
assertNotNull(result);
assertEquals(prefix + ":Server", result);
}
示例4: handleResultFault
import javax.xml.soap.SOAPFault; //导入方法依赖的package包/类
protected void handleResultFault(SOAPFault fault)
{
StringBuilder errorMsg = new StringBuilder();
errorMsg.append("XML/A fault: ");
String faultString = fault.getFaultString();
if (faultString != null)
{
errorMsg.append(faultString);
errorMsg.append("; ");
}
String faultActor = fault.getFaultActor();
if (faultActor != null)
{
errorMsg.append("Actor: ");
errorMsg.append(faultActor);
errorMsg.append("; ");
}
String faultCode = fault.getFaultCode();
if (faultCode != null)
{
errorMsg.append("Code: ");
errorMsg.append(faultCode);
errorMsg.append("; ");
}
throw new JRRuntimeException(errorMsg.toString());
}
示例5: assertSoapFault
import javax.xml.soap.SOAPFault; //导入方法依赖的package包/类
protected void assertSoapFault(SOAPFaultException e, String expectedCode, String expectedMessage) {
SOAPFault fault = e.getFault();
String faultCode = fault.getFaultCode();
display("SOAP fault code: "+faultCode);
assertTrue("Unexpected fault code: "+faultCode, faultCode.endsWith(expectedCode));
String message = e.getMessage();
assertTrue("Unexpected fault message: "+message, message.contains(expectedMessage));
}
示例6: handleResultFault
import javax.xml.soap.SOAPFault; //导入方法依赖的package包/类
protected void handleResultFault(SOAPFault fault)
{
StringBuffer errorMsg = new StringBuffer();
errorMsg.append("XML/A fault: ");
String faultString = fault.getFaultString();
if (faultString != null)
{
errorMsg.append(faultString);
errorMsg.append("; ");
}
String faultActor = fault.getFaultActor();
if (faultActor != null)
{
errorMsg.append("Actor: ");
errorMsg.append(faultActor);
errorMsg.append("; ");
}
String faultCode = fault.getFaultCode();
if (faultCode != null)
{
errorMsg.append("Code: ");
errorMsg.append(faultCode);
errorMsg.append("; ");
}
throw new JRRuntimeException(errorMsg.toString());
}
示例7: send
import javax.xml.soap.SOAPFault; //导入方法依赖的package包/类
public Element send(Element request, URI endpointURL) throws TransportException {
if (log.isDebugEnabled()) {
String requestMessage = XMLUtils.convertNodeToXMLString(request);
log.debug("Request message: %s\n%s" + endpointURL + ":" + requestMessage);
}
Element response = null;
try {
SOAPMessage message = this.createSOAPMessage(request);
//Make the SAAJ Call now
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
SOAPMessage soapResponse = connection.call(message, endpointURL.toURL());
SOAPBody soapBody = soapResponse.getSOAPBody();
boolean hasFault = soapBody.hasFault();
if (hasFault) {
SOAPFault soapFault = soapBody.getFault();
String faultStr = soapFault.getFaultCode() + "::" + soapFault.getFaultString();
throw new RegistryException(faultStr);
}
response = getFirstChildElement(soapBody);
} catch (Exception ex) {
log.error("Exception::" + ex.getMessage(), ex);
throw new TransportException(ex);
}
if (log.isDebugEnabled()) {
String responseMessage = XMLUtils.convertNodeToXMLString(response);
log.debug("Response message: %s" + responseMessage);
}
return response;
}