我是php的新手,并且在执行肥皂请求时全都迷路了。我还有另一个问题,如何在javascript中发送SOAP请求,例如在SoapUI中,我刚刚得到了答复,但是我现在决定使用php而不是Node.js。因为我希望我的php代码做完全相同的事情,所以我将在下面重复我之前的问题:
我有这个WSDL网站,我需要从中获得一些答案。我已经想出了如何在SoapUI中做到这一点,但是我不知道如何在php中做到这一点。我在soapUI中发送的请求如下所示:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:uni="https://uni-login.dk">
<soap:Header/>
<soap:Body>
<uni:hentDataAftaler>
<uni:wsBrugerid>?</uni:wsBrugerid>
<uni:wsPassword>?</uni:wsPassword>
</uni:hentDataAftaler>
</soap:Body>
</soap:Envelope>
我也有wsdl-link:https : //wsiautor.uni-login.dk/wsiautor-v4/ws?WSDL
希望您有一些建议,并告诉我是否需要更多信息来回答我的问题:)
我上一个问题的答案如下
const soapRequest = require('easy-soap-request');
const url = 'https://wsiautor.uni-login.dk/wsiautor-v4/ws';
const headers = {
'Content-Type': 'application/soap+xml;charset=UTF-8',
'soapAction': 'https://wsiautor.uni-login.dk/hentDataAftaler',
};
// example data
const xml = `
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:uni="https://uni-login.dk">
<soap:Header/>
<soap:Body>
<uni:hentDataAftaler>
<uni:wsBrugerid>?</uni:wsBrugerid>
<uni:wsPassword>?</uni:wsPassword>
</uni:hentDataAftaler>
</soap:Body>
</soap:Envelope>
`;
// usage of module
soapRequest(url, headers, xml).then(({response: {body, statusCode}}) => {
console.log(body);
console.log(statusCode);
}).catch((errorBody) => {
console.error(errorBody);
});