我使用Spring-WS消耗下面的WSDL添加到SOAP动作: https://pz.gov.pl/pz-services/SignatureVerification?wsdl 我已经生成的Java类要做到这一点,就像在本教程:https://spring.io/guides/gs/consuming-web-service/春-WS如何属性的请求主体
这个WSDL文件的文件规定,即要求必须有一个属性CALLID和requestTimestamp仅有在下面的例子一样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tpus="http://verification.zp.epuap.gov.pl"> <soapenv:Header/> <soapenv:Body> <tpus:verifySignature callId="6347177294896046332" requestTimestamp="2014-06-30T12:01:30.048+02:00"> <tpus:doc>PD94bWwgdmVyc2E+</tpus:doc> <tpus:attachments> <tpus:Attachment> <tpus:content>PD94bWwgdmVyc2+</tpus:content> <tpus:name>podpis.xml</tpus:name> </tpus:Attachment> </tpus:attachments> </tpus:verifySignature> </soapenv:Body> </soapenv:Envelope>
我的要求是这样的:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-82BA5532C">
<ns3:verifySignature
xmlns:ns3="http://verification.zp.epuap.gov.pl"
xmlns="">
<doc>PD94bWwgdmVyc2E+</doc>
<attachments>
<Attachment>
<content>PD94bWwgdmVyc2+</content>
<name>podpis.xml</name>
</Attachment>
</attachments>
</ns3:verifySignature>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
因此,您可以看到我缺少callId和requestTimestamp属性。如果我的代码发送请求看起来像这样,我可以如何添加它们?
public class TrustedProfileValidator extends WebServiceGatewaySupport {
private static final Logger tpLogger = Logger.getLogger(TrustedProfileValidator.class);
/**
* Trusted profile validator constructor
*/
public TrustedProfileValidator() {
tpLogger.info("Trusted profile validator service.");
}
public VerifySignatureResponse validate(byte[] documentInByte64, ArrayOfAttachment arrayOfAttachments) {
tpLogger.info("Checking trusted profile validation");
VerifySignature request = new VerifySignature();
request.setDoc(documentInByte64);
request.setAttachments(arrayOfAttachments);
return (VerifySignatureResponse) getWebServiceTemplate().marshalSendAndReceive(
"https://int.pz.gov.pl/pz-services/SignatureVerification", request,
new SoapActionCallback("verifySignature"));
}
}
嗯,我想这是错的。在你给的WSDL中,我看不到有关reqGetTpUserObjectsInfo,callId和requestTimestamp的信息;所以或yuo都读取另一个文档o您发布了不同的WSDL –
,因为示例(在文档中)是用于其他方法的,callId和requestTimestamp是必须为每个请求设置的参数。所以我的请求也应该有这些参数。我将编辑这个例子,所以不存在误解 – Dario3d
奇怪的是,在WSDL定义中没有引用属性callId和requestTimestamp以及对象reqGetTpUserObjectsInfo;所以在我看来,或者有一些错误(也许是另一个WSDL),或者在文档中有一些与安全有关的事情(例如ws-security);在ws-security的情况下,有一些参数类似于你编写的参数,但它们是用soap标题写的;你也可以通过使用SOAP-UI来测试WS来获得与spring-ws相同的结果 –