我得到这个例外,因为响应是soapFault.有没有选项可以从这个异常中获取整个xml响应?我需要这个,因为这个xml inst的重要内容, ex.getFaultStringOrReason()但作为此xml末尾的注释
我创建了一个proxy-camel,它接受SOAP(通过HTTP)和RESTful请求,并将它们转发到正确的Web服务.Camel不知道消息结构,它不知道WSDL或任何东西,它根据http头只知道它是否是SOAP.没有CXF端点.
此外,它做了一些处理.例外情况可能发生在那里,例如,当找不到服务或网址无效时.有没有一种简单的方法可以直接从这个驼峰返回有效的SOAPFault?我试着编写一个名为onException的简单处理器.它看起来像这样:
.choice().when().header("SOAP").processRef(ExceptionToSoapProcessor())
Run Code Online (Sandbox Code Playgroud)
应该将任何Exception转换为SOAPFault的处理器如下所示
@Override
public void process(Exchange exchange) throws Exception {
Exception exception = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
Integer responseCode = (Integer) exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE);
QName qName = SoapFault.FAULT_CODE_SERVER;
if (responseCode != null && responseCode < 500) {
qName = SoapFault.FAULT_CODE_CLIENT;
}
SoapFault fault = new SoapFault(exception.getMessage(), qName);
Message outMessage = exchange.getOut();
outMessage.setHeader(Message.RESPONSE_CODE, 500);
outMessage.setFault(true);
outMessage.setBody(fault);
exchange.setException(null);
exchange.removeProperty(Exchange.EXCEPTION_CAUGHT);
exchange.setProperty(Exchange.EXCEPTION_HANDLED, true);
}
Run Code Online (Sandbox Code Playgroud)
但现在我不明白我将如何编组它,响应看起来像这样:
org.apache.cxf.binding.soap.SoapFault: Unauthorized
Run Code Online (Sandbox Code Playgroud)
("未经授权"是实际消息)
PS:之前我使用过dataformat SOAP,但如上所述,我在这个Camel中没有任何ServiceInterface.
我正在使用 spring-ws-2.3.1,在为 web 服务创建客户端时,有时我收到SoapFaultClientException,如下所示,
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>There was a problem with the server so the message could not proceed</faultstring>
<faultactor>InvalidAPI</faultactor>
<detail>
<ns0:serviceException xmlns:ns0="http://www.books.com/interface/v1">
<ns1:messageId xmlns:ns1="http://www.books.org/schema/common/v3_1">5411</ns1:messageId>
<ns1:text xmlns:ns1="http://www.books.org/schema/common/v3_1">Locale is invalid.</ns1:text>
</ns0:serviceException>
</detail>
</SOAP-ENV:Fault>
Run Code Online (Sandbox Code Playgroud)
我正在尝试获取 ServiceException 的“messageId”和“Text”,但我不能。请在下面找到代码,
catch (SoapFaultClientException ex) {
SoapFaultDetail soapFaultDetail = ex.getSoapFault().getFaultDetail(); // <soapFaultDetail> node
// if there is no fault soapFaultDetail ...
if (soapFaultDetail == null) {
throw ex;
}
SoapFaultDetailElement detailElementChild = soapFaultDetail.getDetailEntries().next();
Source detailSource = detailElementChild.getSource();
Object detail = webServiceTemplate.getUnmarshaller().unmarshal(detailSource);
System.out.println("Detail"+detail.toString());//This object prints …Run Code Online (Sandbox Code Playgroud) 我在使用基于Soap的Web服务的projet工作,使用基于Soap的Web服务和2个本地智能手机应用程序(ios和android),经过webservice开发团队的一些编辑后,PHP方面的事情被破坏但智能手机应用程序没有问题.
这是一个重现问题的简单脚本
<?php
error_reporting(E_ALL);
$url = 'http://www.xxxxx.com/service.awws?wsdl';
$sKey = 'thekey';
$client= new SoapClient($url, array('trace' => 1,
'exception' => 1,
'encoding' => 'UTF-8',
'cache_wsdl' => WSDL_CACHE_NONE));
$params = array('sKey' => $sKey, 'nLangID' => 1);
$res = $client->TPGetLocalisationVersion($params);
echo '<pre>Res : ';
print_r($res);
echo '</pre>';
?>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Fatal error: Uncaught SoapFault exception:
[HTTP] Unable to parse URL in /home/xxxx/www/test.php:14 Stack trace: #0 [internal function]:
SoapClient->__doRequest('__call('TPGetLocalisati...', Array) #2 /home/tmpweb/www/test.php(14):
SoapClient->TPGetLocalisationVersion(Array) #3 {main} thrown in /home/xxxx/www/test.php on line 14
Run Code Online (Sandbox Code Playgroud)
方法TPGetLocalisationVersion存在且参数正确.这段代码以前用于工作.
我也可以使用wget从PHP Webserver获取wsdl.
我用一些在线工具测试了WSDL文件,看起来没问题.
有没有调试这个的建议?我确信WSDL没有缓存,因为我在专用服务器上并且在php.ini中完全禁用了WSDL缓存
当使用php对https soap服务器执行soap请求时:s SoapClient失败并带有SoapFault:
faultstring: Could not connect to host faultcode: HTTP
我必须确保soap服务器ssl证书有效,所以我正在使用
<?php
$soap=new SoapClient("mwsdl.wsdl"
,array(
"location"=>"https:examplesoapserver.com"
,"trace"=>1
,"stream_context"=>stream_context_create(array(
"ssl"=>array(
"verify_peer"=>true
,"allow_self_signed"=>false
)
)
)
)
);
Run Code Online (Sandbox Code Playgroud)
但这给了我SoapFault.
我测试了不同的设置:
OK location: has self-signed certificate verify_peer=>true allow_self_signed=>true
OK (without setting verify_peer) location: has self-signed certificate allow_self_signed=>false
NOT OK location: has self-signed certificate verify_peer=>true allow_self_signed=>false
OK (without setting verify_peer) location: ca-signed certificate allow_self_signed=>false
NOT OK location: ca-signed certificate verify_peer=>true allow_self_signed=>false
我有:
php version: 5.3.3 …
最近,安全团队询问我是否可以更改WCF服务中反序列化问题返回的消息。有问题的错误是当他们截取消息并传递Int32范围之外的整数时。
值“ 2147483649”不能解析为类型“ Int32”。
我的回答是,反序列化过程是在执行我的服务的一行之前发生的,这是不可能的。但是,有可能实现这一目标吗?
soapfault ×6
java ×3
soap ×3
php ×2
web-services ×2
.net ×1
apache-camel ×1
soap-client ×1
spring ×1
spring-ws ×1
ssl ×1
wcf ×1