Using wsdl to hit PeopleSoft service in .NET
posted by Bryan on
One of the applications I am testing deals a lot with finance information. However, since most of the data is stored in a remote database, I can't collect or check all the data I want to. We only store a fraction of this information in our schema. I had the wsdl files from the finance department in order to make web service calls. Here's how I did it.
- The wsdl file needs a proxy class to be called from the .NET code. To create this proxy class, use the wsdl.exe tool with the .NET framework.
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\wsdl.exe" /language:CS /protocol:SOAP /namespace:peoplesoft.com /out:myfilename.cs [path]\myfilename.wsdl
- Add the ouput .cs file to your solution in Visual Studio.
- Finally,
C_CURRENCY_CD_CIService service = new C_CURRENCY_CD_CIService();
service.Security = new SecurityTypeShape();
Get__CompIntfc__C_CURRENCY_CD_CITypeShape type = new Get__CompIntfc__C_CURRENCY_CD_CITypeShape();
service.Security.UsernameToken = new UsernameTokenTypeShape();
service.Security.UsernameToken.Username = new UsernameTypeShape();
service.Security.UsernameToken.Password = new PasswordTypeShape();
service.Security.UsernameToken.Username.Value = ConfigurationManager.AppSettings["PeopleSoftUserName"];
service.Security.UsernameToken.Password.Value = ConfigurationManager.AppSettings["PeopleSoftPassword"];
type.CURRENCY_CD = new CURRENCY_CDTypeShape();
type.CURRENCY_CD.Value = currencyCode; //required parameter for this Get method
Get__CompIntfc__C_CURRENCY_CD_CIResponseTypeShape response = service.Get__CompIntfc__C_CURRENCY_CD_CI(type);
The response now holds the SOAP response from the web service call.
Note: You might run into a known problem in XmlSerializer Code Generation component: it cannot handle some cases of nested unbounded elements. The Object Model it creates is not valid: user cannot use it to produce xml messages.
Unfortunately to fix this you have to edit your schema to make sure that all array-like constructs will be handled properly. See website for the rest of the problem description and hack fix: Unable to generate a temporary class.