0

我正在尝试使用 PeopleSoft 网络服务。除了如何在 SOAP 标头中传递用户 ID 和密码之外,我认为我在代码方面有一个不错的开始。我已经使用了 SoapUI 并且有一个有效的 SOAP 请求,但是如何在 c# 中执行此操作?这是我的第一次尝试:

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // put username and password in SOAP header, I hope.
            string header = "<wsse:Security soap:mustUnderstand=\"1\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><wsse:UsernameToken wsu:Id=\"UsernameToken-1\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"><wsse:Username>USERNAME</wsse:Username><wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">PASSWORD</wsse:Password></wsse:UsernameToken><wsse:Security>";

            MessageHeader.CreateHeader ("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-    wssecurity-secext-1.0.xsd", header);


            UTZ_FP134_VENDOR_ADDR utz = new UTZ_FP134_VENDOR_ADDR();
            sendVendorInfoAddrType results;

            getVendorInputType request = new getVendorInputType();

            Console.WriteLine(request.ToString());

            request.getVendrInfo.UTZ_FP134IN_WRK.ADDRESS_SEQ_NUM = "0";
            request.getVendrInfo.UTZ_FP134IN_WRK.VENDOR_ID = "0000000002";
            request.getVendrInfo.UTZ_FP134IN_WRK.VNDR_LOC = "SHARED";

            results = utz.CallUTZ_FP134_VENDOR_ADDR(request);

            Console.WriteLine(results.sendVendorAddressInfo);
            Console.WriteLine(results.sendVendorAddressInfo.UTZ_FP134_TMP.NAME1);
            Console.WriteLine(results.sendVendorAddressInfo.UTZ_FP134_TMP.BANK_ACCOUNT_NUM);
            Console.WriteLine(results.sendVendorAddressInfo.UTZ_FP134_TMP.BNK_ID_NBR);
            Console.WriteLine  (results.sendVendorAddressInfo.UTZ_FP134_TMP.VNDR_LOC);                
            Console.ReadLine();
        }
        catch (Exception ex)
        {
           Console.WriteLine("Hello World " + ex.Message + ex.StackTrace);
           Console.ReadLine();
        }
    }
}
4

0 回答 0