本文整理匯總了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;
}