私は完全なC#初心者であり、これを数時間クラックしようとして成功しませんでした...
C#で使用するSoapClientを構築する必要があります...既存のphpクライアントをc#に移植しようとしています。
基本的に:ユーザーとパスワードを含むSoapヘッダーを使用してリクエストを行う必要があります。これは、送信する必要があるxmlの例です。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webservices.paymentmanager.mycheck.com">
<soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pass</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<SOAP-ENV:Body>
<ns1:testws>
<ns1:x>1</ns1:x>
</ns1:testws>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
VisualStudioの「サービス参照の追加...」を使用しました。
このサービスはうまく機能しており、phpを使用すると見事に機能します。
私が考えたC#:
namespace ConsoleApplication1
{
class Program
{
const String VENDOR_ID = "8723";
const String VENDOR_PASS = "test";
const String VENDOR_USER = "pass";
static void Main(string[] args)
{
try
{
PaymentManager.PaymentManagerPortTypeClient test = new PaymentManager.PaymentManagerPortTypeClient();
int num = test.testws(5);
Console.WriteLine(num);
}
catch( Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
明らかに、私はSoapヘッダーを実装する方法を知らなかったので、「Missing SOAPHeaders」例外(WebServiceから受信)をスローします。