小编Dav*_*row的帖子

Java 6中复合if /或与try/catch相比的成本

如果声明,我们目前有以下化合物......

if ((billingRemoteService == null)
    || billingRemoteService.getServiceHeader() == null
    || !"00".equals(billingRemoteService.getServiceHeader().getStatusCode())
    || (billingRemoteService.getServiceBody() == null) 
    || (billingRemoteService.getServiceBody().getServiceResponse() == null) 
    || (billingRemoteService.getServiceBody().getServiceResponse().getCustomersList() == null) 
    || (billingRemoteService.getServiceBody().getServiceResponse().getCustomersList().getCustomersList() == null) 
    || (billingRemoteService.getServiceBody().getServiceResponse().getCustomersList().getCustomersList().get(0) == null) 
    || (billingRemoteService.getServiceBody().getServiceResponse().getCustomersList().getCustomersList().get(0).getBillAccountInfo() == null)
    || (billingRemoteService.getServiceBody().getServiceResponse().getCustomersList().getCustomersList().get(0).getBillAccountInfo().getEcpdId() == null)) {
        throw new WebservicesException("Failed to get information for Account Number " + accountNo);
}

return billingRemoteService.getServiceBody().getServiceResponse().getCustomersList().getCustomersList().get(0);
Run Code Online (Sandbox Code Playgroud)

这不能简化为......

try {
    //Check to be sure there is an EpcdId.
    (billingRemoteService.getServiceBody().getServiceResponse().getCustomersList().getCustomersList().get(0).getBillAccountInfo().getEcpdId();
    return billingRemoteService.getServiceBody().getServiceResponse().getCustomersList().getCustomersList().get(0);
} catch (NullPointerException npe) {
    throw new WebservicesException("Failed to get information …
Run Code Online (Sandbox Code Playgroud)

java if-statement try-catch

7
推荐指数
2
解决办法
1235
查看次数

使用CXF生成的客户端时出现意外的包装元素

我使用CXF的wsdl2java为web服务生成了一个客户端.

客户端连接正常,但抛出一个假设,抱怨发现的响应与预期的响应不匹配.

May 22, 2013 3:44:46 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://www.service-now.com/cmdb_ci_comm}ServiceNow_cmdb_ci_comm from WSDL: file:/C:/Dev/Workspaces/Eclipse/clim20130508/ServiceNowCXFClient/bin/service-now.wsdl
Invoking getRecords...
May 22, 2013 3:44:51 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://www.service-now.com/foo}ServiceNow_foo#{http://www.service-now.com/foo}getRecords has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unexpected wrapper element getRecordsResponse found.   Expected {http://www.service-now.com/foo}getRecordsResponse.
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:100)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:800)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1592)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1490)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
at com.sun.proxy.$Proxy29.getRecords(Unknown Source)
at com.service_now.cmdb_ci_comm.ServiceNowSoap_ServiceNowSoap_Client.main(ServiceNowSoap_ServiceNowSoap_Client.java:178)
Run Code Online (Sandbox Code Playgroud)

显然,收到的响应与预期的响应不同,后者包括命名空间. …

java soap wsdl cxf

7
推荐指数
1
解决办法
6626
查看次数

使用第三个作为链接表连接两个表,包括空条目

我已经看了很多类似的问题,但还没有发现/找到下面问题的正确解决方案.

给出以下三个表:

account
    profile_id number (nullable)
    bill_acct varchar
    status varchar (nullable)
    remarks varchar (nullable)


stage
    ecpd_profile_id number (nullable)
    bill_account varchar (nullable)
    account_class varchar (nullable)

profile
    ecpd_profile_id number
    reg_prof_id number
Run Code Online (Sandbox Code Playgroud)

我需要创建一个连接来选择以下内容:

account.bill_act, account.status, account.remarks, stage.account_class
Run Code Online (Sandbox Code Playgroud)

哪里

profile.ecpd_profile_id = (given number)
Run Code Online (Sandbox Code Playgroud)

account.profile_id并且profile.reg_prof_id是等价的

stage.ecpd_profile_id并且profile.ecpd_profile_id是等价的

stage.bill_acct并且account.bill_acct是等价的

我试过以下......

select
    account.bill_acct,
    account.status,
    account.remarks,
    stage.account_class
from
    registration_account account
        join registration_profile profile
            on account.profile_id = profile.reg_prof_id
        join acct_stg stage
            on stage.ecpd_profile_id = profile.ecpd_profile_id
                and stage.bill_acct = account.bill_acct
where
    profile.ecpd_profile_id …
Run Code Online (Sandbox Code Playgroud)

sql oracle join ansi-sql

5
推荐指数
1
解决办法
2万
查看次数

在 React Native 中 HitRect 如何与 Pressable 一起使用?

我们计划从 TouchableOpacity 切换到 Pressable。

我们希望使用 Pressable 的可选 HitRec 来确保我们的命中目标大小适当(我们将计算尺寸)以实现可访问性。

Pressable 文档没有有关使用 HitRect 的信息。我在其他地方找到了对 HitRect 的引用,但它们也没有有用的信息。

任何人都可以描述如何使用 Pressable 实现 HitRect 吗?

react-native pressable

3
推荐指数
1
解决办法
1370
查看次数

Wicket 7无法在表单树中找到组件

我正在创建一个允许管理员编辑用户信息的表单。但是,当我运行该应用程序时,我收到以下错误消息:

Last cause: Unable to find component with id 'editUserFirstname' in [Form [Component id = userEditForm]]
    Expected: 'userEditForm:editUserFirstname'.
    Found with similar names: ''
Run Code Online (Sandbox Code Playgroud)

但据我所知,我的editUserFirstname字段受userEditForm限制。

这是我的代码...

EditUserPage.html

<form wicket:id="userEditForm" class="userEditForm">
    <fieldset>
        <legend>
            <wicket:message key="userEditLegendKey"></wicket:message>
        </legend>
        <table id="userEditFormTable">
            <tr>
                <td>
                    <label for="editUserFirstname">
                        <wicket:message key="firstnameKey"></wicket:message>
                    </label>
                    <input wicket:id="editUserFirstname" id="editUserFirstname" type="text" size="40"/>
                    <label for="editUserSurname">
                        <wicket:message key="surnameKey"></wicket:message>
                    </label>
                    <input wicket:id="editUserSurname" id="editUserSurname" type="text" size="40"/>
                    <label for="editUserUsername">
                        <wicket:message key="usernameKey"></wicket:message>
                    </label>
                    <input wicket:id="editUserUsername" id="editUserUsername" type="text" size="40"/>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" wicket:id="savebutton" value="save"/>
                    <input type="submit" wicket:id="cancelbutton" value="cancel"> …
Run Code Online (Sandbox Code Playgroud)

java forms wicket

2
推荐指数
1
解决办法
1789
查看次数

如何为抢占式HTTP身份验证配置CXF生成的客户端?

我有一个由CXF使用本地wsdl文件生成的客户端.客户端连接正常,我从Web服务器收到预期的401错误.

我遇到的问题是无法在客户端中正确配置抢占式身份验证.

我尝试过很多东西都无济于事.Web上的大多数示例似乎都集中在Spring上,而不是简单的旧Java方法.

我包括客户的主要部分.如果有人能给我一个如何配置它的例子,我会很感激.请注意,我不是在寻找任何花哨的东西.我只需要能够验证并调用服务.

public final class ServiceNowSoap_ServiceNowSoap_Client {

private static final QName SERVICE_NAME = new QName(
        "http://www.service-now.com/foo",
        "ServiceNow_foo");

private ServiceNowSoap_ServiceNowSoap_Client() {
}

public static void main(String args[]) throws java.lang.Exception {
    URL wsdlURL = ServiceNowCmdbCiComm.WSDL_LOCATION;
    if (args.length > 0 && args[0] != null && !"".equals(args[0])) {
        File wsdlFile = new File(args[0]);
        try {
            if (wsdlFile.exists()) {
                wsdlURL = wsdlFile.toURI().toURL();
            } else {
                wsdlURL = new URL(args[0]);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    ServiceNowFoo ss = new ServiceNowFoo(wsdlURL, …
Run Code Online (Sandbox Code Playgroud)

java authentication soap cxf preemptive

1
推荐指数
1
解决办法
6361
查看次数