Created
August 13, 2023 14:21
-
-
Save mouseos/b2012acb4a50211900e8beedd46cb976 to your computer and use it in GitHub Desktop.
soap apiをいろんな言語から使う練習
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# SOAP endpoint URL | |
URL="http://www.soapclient.com/xml/soapresponder.wsdl" | |
# Create the SOAP request message | |
SOAP_REQUEST=$(cat <<EOF | |
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.SoapClient.com/xml/SoapResponder.wsdl"> | |
<soapenv:Header/> | |
<soapenv:Body> | |
<web:Method1> | |
<web:bstrParam1>param1</web:bstrParam1> | |
<web:bstrParam2>param2</web:bstrParam2> | |
</web:Method1> | |
</soapenv:Body> | |
</soapenv:Envelope> | |
EOF | |
) | |
# Send the SOAP request using curl | |
curl -X POST \ | |
-H "Content-Type: text/xml" \ | |
-H "SOAPAction: http://www.SoapClient.com/SoapObject" \ | |
--data-binary "$SOAP_REQUEST" \ | |
"$URL" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendSoapRequest() { | |
var url = 'http://www.soapclient.com/xml/soapresponder.wsdl'; | |
// Create the SOAP request message | |
var soapRequest = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.SoapClient.com/xml/SoapResponder.wsdl">'; | |
soapRequest += '<soapenv:Header/>'; | |
soapRequest += '<soapenv:Body>'; | |
soapRequest += '<web:Method1>'; | |
soapRequest += '<web:bstrParam1>hey</web:bstrParam1>'; | |
soapRequest += '<web:bstrParam2>ya</web:bstrParam2>'; | |
soapRequest += '</web:Method1>'; | |
soapRequest += '</soapenv:Body>'; | |
soapRequest += '</soapenv:Envelope>'; | |
// Set the options for the HTTP request | |
var options = { | |
method: 'post', | |
contentType: 'text/xml', | |
headers: { | |
'SOAPAction': 'http://www.SoapClient.com/SoapObject' | |
}, | |
payload: soapRequest | |
}; | |
// Send the SOAP request | |
var response = UrlFetchApp.fetch(url, options); | |
// Log the SOAP response | |
Logger.log(response.getContentText()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zeep | |
wsdl = 'http://www.soapclient.com/xml/soapresponder.wsdl' | |
client = zeep.Client(wsdl=wsdl) | |
print(client.service.Method1('param1', 'param2')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment