List of usage examples for javax.xml.soap SOAPFault getDetail
public Detail getDetail();
From source file:com.javector.soaj.provider.generatedwsdl.TestProviderGeneratedWsdl.java
public void testProvider() throws Exception { SoajProviderService service = new SoajProviderService(); SoajProviderPortType port = service.getSoajProviderPort(); Item item = new Item(); item.setPrice(3.99);//from w w w .j a v a 2 s . c o m item.setProductName("Diet Coke"); item.setQuantity(BigInteger.valueOf(6)); Items items = new Items(); items.getItem().add(item); BillToType billTo = new BillToType(); billTo.setCity("Canton"); billTo.setPhone("(973) 243-8776"); billTo.setState("OH"); billTo.setStreet("125 Main Street"); billTo.setZip("98134"); PurchaseOrder po = new PurchaseOrder(); po.setBillTo(billTo); po.setItems(items); BillToType response; try { response = port.getBillTo(po); } catch (SOAPFaultException sfe) { SOAPFault sf = sfe.getFault(); System.out.println("SOAPFault:" + IOUtil.NL + XmlUtil.toFormattedString(sf)); sf.getDetail(); throw sfe; } assertNotNull("SOAP Response should not be null.", response); System.out.println("bill to city = " + response.getCity()); assertEquals("Canton", response.getCity()); }
From source file:com.javector.soaj.provider.generatedwsdl.TestProviderGeneratedWsdl.java
public void testProviderEJB21Invocation() throws Exception { SoajProviderService service = new SoajProviderService(); SoajProviderPortType port = service.getSoajProviderPort(); Item item = new Item(); item.setPrice(3.99);/*from ww w.jav a2s. c om*/ item.setProductName("Diet Coke"); item.setQuantity(BigInteger.valueOf(6)); Items items = new Items(); items.getItem().add(item); BillToType billTo = new BillToType(); billTo.setCity("Canton"); billTo.setPhone("(973) 243-8776"); billTo.setState("OH"); billTo.setStreet("125 Main Street"); billTo.setZip("98134"); PurchaseOrder po = new PurchaseOrder(); po.setBillTo(billTo); po.setItems(items); BillToType response; try { response = port.getBillToFromEJB21(po); } catch (SOAPFaultException sfe) { SOAPFault sf = sfe.getFault(); System.out.println("SOAPFault:" + IOUtil.NL + XmlUtil.toFormattedString(sf)); sf.getDetail(); throw sfe; } assertNotNull("SOAP Response should not be null.", response); System.out.println("bill to city = " + response.getCity()); assertEquals("Canton", response.getCity()); }
From source file:com.legstar.proxy.invoke.jaxws.WebServiceInvoker.java
/** * Try to extract something meaningful from a SOAP Fault. * //from w w w . j ava2s . com * @param e the SOAP Fault exception * @return a fault description */ @SuppressWarnings("rawtypes") public String getFaultReasonText(final SOAPFaultException e) { if (_log.isDebugEnabled()) { SOAPFault fault = e.getFault(); if (fault != null) { QName code = fault.getFaultCodeAsQName(); String string = fault.getFaultString(); String actor = fault.getFaultActor(); _log.debug("SOAP fault contains: "); _log.debug(" Fault code = " + code.toString()); _log.debug(" Local name = " + code.getLocalPart()); _log.debug(" Namespace prefix = " + code.getPrefix() + ", bound to " + code.getNamespaceURI()); _log.debug(" Fault string = " + string); if (actor != null) { _log.debug(" Fault actor = " + actor); } Detail detail = fault.getDetail(); if (detail != null) { Iterator entries = detail.getDetailEntries(); while (entries.hasNext()) { DetailEntry newEntry = (DetailEntry) entries.next(); String value = newEntry.getValue(); _log.debug(" Detail entry = " + value); } } } else { _log.debug(e); } } SOAPFault fault = e.getFault(); if (fault != null) { StringBuffer faultMessage = new StringBuffer(e.getFault().getFaultString()); Detail detail = fault.getDetail(); if (detail != null) { Iterator entries = detail.getDetailEntries(); while (entries.hasNext()) { DetailEntry newEntry = (DetailEntry) entries.next(); faultMessage.append(" [" + newEntry.getValue() + "]"); } } return faultMessage.toString(); } else { return e.getMessage(); } }
From source file:org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider.java
public Source invoke(Source request) { Source response = null;/*from w w w. j a v a 2 s . c om*/ try { RequestSecurityTokenType rst = convertToJAXBObject(request); Object operationImpl = null; List<?> objectList = rst.getAny(); for (int i = 0; i < objectList.size(); i++) { Object obj = objectList.get(i); if (obj instanceof JAXBElement) { QName qname = ((JAXBElement<?>) obj).getName(); if (qname.equals(new QName(WSTRUST_13_NAMESPACE, WSTRUST_REQUESTTYPE_ELEMENTNAME))) { operationImpl = operationMap.get(((JAXBElement<?>) obj).getValue().toString()); break; } } } if (operationImpl == null) { throw new Exception("Implementation for this operation not found."); } Method[] methods = operationImpl.getClass().getMethods(); for (int x = 0; x < methods.length; x++) { Class<?>[] paramClass = methods[x].getParameterTypes(); if (paramClass.length == 1 && paramClass[0].equals(rst.getClass())) { RequestSecurityTokenResponseCollectionType tokenResponse = (RequestSecurityTokenResponseCollectionType) methods[x] .invoke(operationImpl, rst); if (tokenResponse == null) { throw new Exception("Error in implementation class."); } response = new JAXBSource(jaxbContext, new ObjectFactory().createRequestSecurityTokenResponseCollection(tokenResponse)); return response; } } } catch (Exception e) { LOG.error(e); try { SOAPFault fault = soapFactory.createFault(); if (e.getMessage() == null) { fault.setFaultString(e.getCause().getMessage()); } else { fault.setFaultString(e.getMessage()); } Detail detail = fault.addDetail(); detail = fault.getDetail(); QName qName = new QName(WSTRUST_13_NAMESPACE, "Fault", "ns"); DetailEntry de = detail.addDetailEntry(qName); qName = new QName(WSTRUST_13_NAMESPACE, "ErrorCode", "ns"); SOAPElement errorElement = de.addChildElement(qName); StackTraceElement[] ste = e.getStackTrace(); errorElement.setTextContent(ste[0].toString()); throw new SOAPFaultException(fault); } catch (SOAPException e1) { LOG.error(e1); } } return response; }
From source file:org.apache.juddi.v3.client.mapping.MapUDDIv2Tov3.java
private static List<Result> MapFault(SOAPFault result) { List<Result> r = new ArrayList<Result>(); if (result == null) { return r; }//ww w.j a va2s .c o m if (result.getDetail() != null) { while (result.getDetail().getDetailEntries().hasNext()) { Object next = result.getDetail().getDetailEntries().next(); if (next instanceof DispositionReport) { DispositionReport z = (DispositionReport) next; Result x = new Result(); r.addAll(MapResult(z.getFaultInfo().getResult())); } logger.warn("unable to parse fault detail, type:" + next.getClass().getCanonicalName() + " " + next.toString()); } } return r; }
From source file:org.openhab.binding.fritzboxtr064.internal.Tr064Comm.java
/** * Populates local static mapping table. * Sets the parser based on the itemcommand -> soap value parser "svp" * anonymous method for each mapping.//from w ww . ja va2s.co m */ // TODO: refactor to read from config file later? private void generateItemMappings() { // services available from fbox. Needed for e.g. wifi select 5GHz/Guest Wifi if (_allServices.isEmpty()) { // no services are known yet? readAllServices(); } // Mac Online Checker SingleItemMap imMacOnline = SingleItemMap.builder().itemCommand("maconline") .serviceId("urn:LanDeviceHosts-com:serviceId:Hosts1").itemArgumentName("NewActive") .configArgumentNames("NewMACAddress").readServiceCommand("GetSpecificHostEntry") .soapValueParser(new SoapValueParser() { @Override protected String parseValueFromSoapFault(ItemConfiguration itemConfiguration, SOAPFault soapFault, ItemMap mapping) { String value = null; Detail detail = soapFault.getDetail(); if (detail != null) { NodeList nlErrorCode = detail.getElementsByTagName("errorCode"); Node nErrorCode = nlErrorCode.item(0); String errorCode = nErrorCode.getTextContent(); if (errorCode.equals("714")) { value = "MAC not known to FritzBox!"; logger.debug(value); } } if (value == null) { value = super.parseValueFromSoapFault(itemConfiguration, soapFault, mapping); } return value; } }).build(); addItemMap(imMacOnline); addItemMap(new MultiItemMap( Arrays.asList("modelName", "manufacturerName", "softwareVersion", "serialNumber"), "GetInfo", "urn:DeviceInfo-com:serviceId:DeviceInfo1", name -> "New" + WordUtils.capitalize(name))); addItemMap(SingleItemMap.builder().itemCommand("wanip") .serviceId("urn:WANPPPConnection-com:serviceId:WANPPPConnection1") .itemArgumentName("NewExternalIPAddress").readServiceCommand("GetExternalIPAddress").build()); addItemMap(SingleItemMap.builder().itemCommand("externalWanip") .serviceId("urn:WANIPConnection-com:serviceId:WANIPConnection1") .itemArgumentName("NewExternalIPAddress").readServiceCommand("GetExternalIPAddress").build()); // WAN Status addItemMap(new MultiItemMap( Arrays.asList("wanWANAccessType", "wanLayer1UpstreamMaxBitRate", "wanLayer1DownstreamMaxBitRate", "wanPhysicalLinkStatus"), "GetCommonLinkProperties", "urn:WANCIfConfig-com:serviceId:WANCommonInterfaceConfig1", name -> name.replace("wan", "New"))); addItemMap(SingleItemMap.builder().itemCommand("wanTotalBytesSent") .serviceId("urn:WANCIfConfig-com:serviceId:WANCommonInterfaceConfig1") .itemArgumentName("NewTotalBytesSent").readServiceCommand("GetTotalBytesSent").build()); addItemMap(SingleItemMap.builder().itemCommand("wanTotalBytesReceived") .serviceId("urn:WANCIfConfig-com:serviceId:WANCommonInterfaceConfig1") .itemArgumentName("NewTotalBytesReceived").readServiceCommand("GetTotalBytesReceived").build()); // DSL Status addItemMap(new MultiItemMap( Arrays.asList("dslEnable", "dslStatus", "dslUpstreamCurrRate", "dslDownstreamCurrRate", "dslUpstreamMaxRate", "dslDownstreamMaxRate", "dslUpstreamNoiseMargin", "dslDownstreamNoiseMargin", "dslUpstreamAttenuation", "dslDownstreamAttenuation"), "GetInfo", "urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1", name -> name.replace("dsl", "New"))); addItemMap(new MultiItemMap(Arrays.asList("dslFECErrors", "dslHECErrors", "dslCRCErrors"), "GetStatisticsTotal", "urn:WANDSLIfConfig-com:serviceId:WANDSLInterfaceConfig1", name -> name.replace("dsl", "New"))); // Wifi 2,4GHz SingleItemMap imWifi24Switch = SingleItemMap.builder().itemCommand("wifi24Switch") .serviceId("urn:WLANConfiguration-com:serviceId:WLANConfiguration1").itemArgumentName("NewEnable") .readServiceCommand("GetInfo").writeServiceCommand("SetEnable").build(); addItemMap(imWifi24Switch); // wifi 5GHz SingleItemMap imWifi50Switch = SingleItemMap.builder().itemCommand("wifi50Switch") .serviceId("urn:WLANConfiguration-com:serviceId:WLANConfiguration2").itemArgumentName("NewEnable") .readServiceCommand("GetInfo").writeServiceCommand("SetEnable").build(); // guest wifi SingleItemMap imWifiGuestSwitch = SingleItemMap.builder().itemCommand("wifiGuestSwitch") .serviceId("urn:WLANConfiguration-com:serviceId:WLANConfiguration3").itemArgumentName("NewEnable") .readServiceCommand("GetInfo").writeServiceCommand("SetEnable").build(); // check if 5GHz wifi and/or guest wifi is available. Tr064Service svc5GHzWifi = determineServiceByItemMapping(imWifi50Switch); Tr064Service svcGuestWifi = determineServiceByItemMapping(imWifiGuestSwitch); if (svc5GHzWifi != null && svcGuestWifi != null) { // WLANConfiguration3+2 present -> guest wifi + 5Ghz present // prepared properly, only needs to be added addItemMap(imWifi50Switch); addItemMap(imWifiGuestSwitch); logger.debug("Found 2,4 Ghz, 5Ghz and Guest Wifi"); } if (svc5GHzWifi != null && svcGuestWifi == null) { // WLANConfiguration3 not present but 2 -> no 5Ghz Wifi // available but Guest Wifi // remap itemMap for Guest Wifi from 3 to 2 imWifiGuestSwitch.setServiceId("urn:WLANConfiguration-com:serviceId:WLANConfiguration2"); addItemMap(imWifiGuestSwitch);// only add guest wifi, no 5Ghz logger.debug("Found 2,4 Ghz and Guest Wifi"); } if (svc5GHzWifi == null && svcGuestWifi == null) { // WLANConfiguration3+2 not present > no 5Ghz Wifi or Guest // Wifi logger.debug("Found 2,4 Ghz Wifi"); } // Phonebook Download // itemcommand is dummy: not a real item ItemMap imPhonebook = SingleItemMap.builder().itemCommand("phonebook") .serviceId("urn:X_AVM-DE_OnTel-com:serviceId:X_AVM-DE_OnTel1").configArgumentNames("NewPhonebookID") .itemArgumentName("NewPhonebookURL").readServiceCommand("GetPhonebook").build(); addItemMap(imPhonebook); // TAM (telephone answering machine) Switch SingleItemMap imTamSwitch = SingleItemMap.builder().itemCommand("tamSwitch") .serviceId("urn:X_AVM-DE_TAM-com:serviceId:X_AVM-DE_TAM1").configArgumentNames("NewIndex") .itemArgumentName("NewEnable").readServiceCommand("GetInfo").writeServiceCommand("SetEnable") .build(); addItemMap(imTamSwitch); // New Messages per TAM ID // two requests needed: First gets URL to download tam info from, 2nd contains // info of messages SingleItemMap imTamNewMessages = SingleItemMap.builder().itemCommand("tamNewMessages") .serviceId("urn:X_AVM-DE_TAM-com:serviceId:X_AVM-DE_TAM1").configArgumentNames("NewIndex") .itemArgumentName("NewURL").readServiceCommand("GetMessageList") .soapValueParser(new SoapValueParser() { @Override protected String parseValueFromSoapBody(ItemConfiguration itemConfiguration, SOAPBody soapBody, ItemMap mapping) { String value = null; // extract URL from soap response String url = super.parseValueFromSoapBody(itemConfiguration, soapBody, mapping); if (url != null) { Document xmlTamInfo = getFboxXmlResponse(url); if (xmlTamInfo != null) { logger.debug("Parsing xml message TAM info {}", Helper.documentToString(xmlTamInfo)); NodeList nlNews = xmlTamInfo.getElementsByTagName("New"); // get all Nodes containing // "new", indicating message // was not listened to // When <new> contains 1 -> message is new, when 0, message not new -> Counting // 1s int newMessages = 0; for (int i = 0; i < nlNews.getLength(); i++) { if (nlNews.item(i).getTextContent().equals("1")) { newMessages++; } } value = Integer.toString(newMessages); logger.debug("Parsed new messages as: {}", value); } else { logger.warn("Failed to read TAM info from URL {}", url); // cause was already logged earlier } } return value; } }).build(); addItemMap(imTamNewMessages); // Missed calls // two requests: 1st fetches URL to download call list, 2nd fetches xml call // list SingleItemMap imMissedCalls = SingleItemMap.builder().itemCommand("missedCallsInDays") .serviceId("urn:X_AVM-DE_OnTel-com:serviceId:X_AVM-DE_OnTel1").itemArgumentName("NewCallListURL") .readServiceCommand("GetCallList").configArgumentNames("NewDays") .soapValueParser(new SoapValueParser() { @Override protected String parseValueFromSoapBody(ItemConfiguration itemConfiguration, SOAPBody soapBody, ItemMap mapping) { String value = null; // extract URL from soap response String url = super.parseValueFromSoapBody(itemConfiguration, soapBody, mapping); // extract how many days of call list should be examined for missed calls String days = "3"; // default if (!itemConfiguration.getArgumentValues().isEmpty()) { days = itemConfiguration.getArgumentValues().get(0); // set the days as defined in item // config. // Otherwise default value of 3 is used } if (url != null) { // only get missed calls of the last x days url = url + "&days=" + days; logger.debug("Downloading call list using url {}", url); Document callListInfo = getFboxXmlResponse(url); // download call list if (callListInfo != null) { logger.debug("Parsing xml message call list info {}", Helper.documentToString(callListInfo)); NodeList nlTypes = callListInfo.getElementsByTagName("Type"); // get all Nodes // containing "Type". Type // 2 => missed // When <type> contains 2 -> call was missed -> Counting only 2 entries int missedCalls = 0; for (int i = 0; i < nlTypes.getLength(); i++) { if (nlTypes.item(i).getTextContent().equals("2")) { missedCalls++; } } value = Integer.toString(missedCalls); logger.debug("Parsed new messages as: {}", value); } else { logger.warn("Failed to read call list info from URL {}", url); // cause was already logged earlier } } return value; } }).build(); addItemMap(imMissedCalls); // call deflection SingleItemMap callDeflection = SingleItemMap.builder().itemCommand("callDeflectionSwitch") .serviceId("urn:X_AVM-DE_OnTel-com:serviceId:X_AVM-DE_OnTel1") .configArgumentNames("NewDeflectionId").itemArgumentName("NewEnable") .readServiceCommand("GetDeflection").writeServiceCommand("SetDeflectionEnable").build(); addItemMap(callDeflection); }
From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java
/** * check SOAP reply for Error, return fault Code * * @param reply the message to check//from w ww . j a v a 2s . com * @param aReturn ArrayList containing faultcode,faultstring,faultactor */ private boolean soapFault(final SOAPMessage reply, final String[] faults) throws SOAPException { SOAPPart sp = reply.getSOAPPart(); SOAPEnvelope envelope = sp.getEnvelope(); SOAPBody body = envelope.getBody(); if (!body.hasFault()) { return false; } SOAPFault fault = body.getFault(); faults[0] = fault.getFaultCode(); faults[1] = fault.getFaultString(); faults[2] = fault.getFaultActor(); // probably not neccessary with Microsoft; Detail detail = fault.getDetail(); if (detail == null) { return true; } String detailMsg = ""; //$NON-NLS-1$ Iterator it = detail.getDetailEntries(); for (; it.hasNext();) { DetailEntry det = (DetailEntry) it.next(); Iterator ita = det.getAllAttributes(); for (boolean cont = false; ita.hasNext(); cont = true) { Name name = (Name) ita.next(); if (cont) { detailMsg += "; "; //$NON-NLS-1$ } detailMsg += name.getLocalName(); detailMsg += " = "; //$NON-NLS-1$ detailMsg += det.getAttributeValue(name); } } faults[3] = detailMsg; return true; }