Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HTTP响应';401:未经授权';将NTLM与Wildfly一起使用_Java_Sharepoint_Jboss_Jax Ws_Ntlm - Fatal编程技术网

Java HTTP响应';401:未经授权';将NTLM与Wildfly一起使用

Java HTTP响应';401:未经授权';将NTLM与Wildfly一起使用,java,sharepoint,jboss,jax-ws,ntlm,Java,Sharepoint,Jboss,Jax Ws,Ntlm,当SOAP请求太长时,我们使用WildFly 11中的JAX-WS(ApacheCxf在引擎盖下)得到'401:Unauthorized'作为响应 我们正在使用NTLM协议将一个SOAP Web服务从WildFly调用到SharePoint 如果请求大小较短,则可以正常工作,但如果请求“较大”(例如1MB的SOAP消息),则会失败,并出现错误HTTP401。我们使用此web服务发送图像,但编码为base64二进制 我们尝试使用soapui调用该服务,它成功了,因此应用服务器中似乎出现了问题。可能

当SOAP请求太长时,我们使用WildFly 11中的JAX-WS(ApacheCxf在引擎盖下)得到
'401:Unauthorized'
作为响应

我们正在使用NTLM协议将一个SOAP Web服务从WildFly调用到SharePoint

如果请求大小较短,则可以正常工作,但如果请求“较大”(例如1MB的SOAP消息),则会失败,并出现错误HTTP401。我们使用此web服务发送图像,但编码为base64二进制

我们尝试使用soapui调用该服务,它成功了,因此应用服务器中似乎出现了问题。可能会发生什么,我们可以采取什么变通办法

更新:Jira问题似乎与此类似

我们的客户端代码非常简单,我们发送一个BASE64字节数组(s:base64Binary):

例外情况如下:

Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with http://customerendpoint/service.asmx
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1581)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1533)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1336)
    at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56)
    at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:215)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:652)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:516)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:138)
    ... 110 more

魔法就发生在这里
httpClientPolicy.setAllowChunking(false)
。将此设置为false解决了问题

代码示例

Client client = ClientProxy.getClient(servicePort);

HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();

//This is the magic line. Setting this to false solved the problem
httpClientPolicy.setAllowChunking(false);

http.setClient(httpClientPolicy);
依赖关系

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-simple</artifactId>
    <version>3.0.5</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>3.0.5</version>
    <scope>provided</scope>
</dependency>

org.apache.cxf
cxf rt前端简单
3.0.5
假如
org.apache.cxf
cxf rt传输http
3.0.5
假如
jboss部署结构.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.apache.cxf.impl">
                <imports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </imports>
            </module>
        </dependencies>
    </deployment>
</jboss-deployment-structure>


一个“大”文件的大小是多少字节?这可能是Sharepoint服务器上的文件上载大小限制,但奇怪的是,它的回复是401。检查technet,例如@jordiburgos大约1MB或2MB的消息(整个SOAP信封)失败了,但我们已经看到了大小小得多的失败。同样,我们将以Base64二进制格式向第三方API发送图像。@EugèneAdell感谢Eugene,但我们怀疑问题出在客户端(Apache CXF),这可能是一个but或我们缺少的东西。
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-simple</artifactId>
    <version>3.0.5</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>3.0.5</version>
    <scope>provided</scope>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="org.apache.cxf.impl">
                <imports>
                    <include path="META-INF"/>
                    <include path="META-INF/cxf"/>
                </imports>
            </module>
        </dependencies>
    </deployment>
</jboss-deployment-structure>