我使用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相同的結果 –