我正在连接到两个具有相同结构(相同输入、相同输出)但端点和方法名称不同的 SAP WS/SOAP。
我已将两个 WS 的描述符作为 Web 参考导入,现在我将它们与以下内容一起使用:
bool pBG = true;
sapWSBG.ZbgPogon inputBG = new sapWSBG.ZbgPogon();
sapWSBG.ZbgPogonResponse responseBG = new sapWSBG.ZbgPogonResponse();
sapWSRO.ZroPogon inputRO = new sapWSRO.ZroPogon();
sapWSRO.ZroPogonResponse responseRO = new sapWSRO.ZroPogonResponse();
if (pBG)
{
//set input params
inputBG.IntHeader = getHeader((string)pPlant);
inputBG.Pogon = (String)pPlant;
LogXml(inputBG, "input");
//make the call
responseBG = clientBG.ZbgPogon(inputBG);
LogXml(responseBG, "response");
}
else
{
//set input params
inputRO.IntHeader = getHeader((string)pPlant);
inputRO.Pogon = (String)pPlant;
LogXml(inputRO, "input");
//make the call
responseRO = clientRO.ZroPogon(inputRO);
LogXml(responseRO, "response");
}
//process data in response(s)
...
为了不构建两个单独的程序集并避免重复相同的代码,有没有办法只向每个服务器发出请求而保持其余代码相同?