سؤال

أتساءل عما إذا كان أي شخص قد حقق أي نجاح في استخدام وظيفة JDEdwards XMLInterop.لقد كنت أستخدمه لفترة من الوقت (باستخدام PInvoc بسيط، سيتم نشر الرمز لاحقًا).إنني أتطلع لمعرفة ما إذا كانت هناك طريقة أفضل و/أو أكثر قوة.

شكرًا.

هل كانت مفيدة؟

المحلول

كما وعدناكم، إليك رمز التكامل مع JDEdewards باستخدام XML.إنها خدمة ويب، ولكن يمكن استخدامها كما تراه مناسبًا.

namespace YourNameSpace

{

/// <summary>
/// This webservice allows you to submit JDE XML CallObject requests via a c# webservice
/// </summary>
[WebService(Namespace = "http://WebSite.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class JdeBFService : System.Web.Services.WebService
{
    private string _strServerName;
    private UInt16 _intServerPort;
    private Int16 _intServerTimeout;

    public JdeBFService()
    {
        // Load JDE ServerName, Port, & Connection Timeout from the Web.config file.
        _strServerName = ConfigurationManager.AppSettings["JdeServerName"];
        _intServerPort = Convert.ToUInt16(ConfigurationManager.AppSettings["JdePort"], CultureInfo.InvariantCulture);
        _intServerTimeout = Convert.ToInt16(ConfigurationManager.AppSettings["JdeTimeout"], CultureInfo.InvariantCulture);

    }

    /// <summary>
    /// This webmethod allows you to submit an XML formatted jdeRequest document
    /// that will call any Master Business Function referenced in the XML document
    /// and return a response.
    /// </summary>
    /// <param name="Xml"> The jdeRequest XML document </param>
    [WebMethod]
    public XmlDocument JdeXmlRequest(XmlDocument xmlInput)
    {
        try
        {
            string outputXml = string.Empty;
            outputXml = NativeMethods.JdeXmlRequest(xmlInput, _strServerName, _intServerPort, _intServerTimeout);

            XmlDocument outputXmlDoc = new XmlDocument();
            outputXmlDoc.LoadXml(outputXml);
            return outputXmlDoc;
        }
        catch (Exception ex)
        {
            ErrorReporting.SendEmail(ex);
            throw;
        }
    }
}

/// <summary>
/// This interop class uses pinvoke to call the JDE C++ dll.  It only has one static function.
/// </summary>
/// <remarks>
/// This class calls the xmlinterop.dll which can be found in the B9/system/bin32 directory.  
/// Copy the dll to the webservice project's /bin directory before running the project.
/// </remarks>
internal static class NativeMethods
{
    [DllImport("xmlinterop.dll",
        EntryPoint = "_jdeXMLRequest@20",
        CharSet = CharSet.Auto,
        ExactSpelling = false,
        CallingConvention = CallingConvention.StdCall,
        SetLastError = true)]
    private static extern IntPtr jdeXMLRequest([MarshalAs(UnmanagedType.LPWStr)] StringBuilder server, UInt16 port, Int32 timeout, [MarshalAs(UnmanagedType.LPStr)] StringBuilder buf, Int32 length);

    public static string JdeXmlRequest(XmlDocument xmlInput, string strServerName, UInt16 intPort, Int32 intTimeout)
    {
        StringBuilder sbServerName = new StringBuilder(strServerName);
        StringBuilder sbXML = new StringBuilder();
        XmlWriter xWriter = XmlWriter.Create(sbXML);
        xmlInput.WriteTo(xWriter);
        xWriter.Close();

        string result = Marshal.PtrToStringAnsi(jdeXMLRequest(sbServerName, intPort, intTimeout, sbXML, sbXML.Length));

        return result;
    }
}

}

عليك أن ترسل له رسائل مثل الرسالة التالية:

<jdeRequest type='callmethod' user='USER' pwd='PWD' environment='ENV'>
  <callMethod name='GetEffectiveAddress' app='JdeWebRequest' runOnError='no'>
    <params>
      <param name='mnAddressNumber'>10000</param>
    </params>
  </callMethod>
</jdeRequest>

نصائح أخرى

لأي شخص يحاول القيام بذلك، هناك بعض التبعيات لـ xmlinterop.dll.

ستجد هذه الملفات على العميل الدهون هنا ->c:\E910\system\bin32

سيؤدي هذا إلى إنشاء "عميل رفيع"

PSThread.dll
icudt32.dll
icui18n.dll
icuuc.dll
jdel.dll
jdeunicode.dll
libeay32.dll
msvcp71.dll
ssleay32.dll
ustdio.dll
xmlinterop.dll

لقد قمت بتغيير خدمة الويب JDE الخاصة بنا لاستخدام XML Interop بعد رؤية هذا الرمز، ولم نواجه أي مشاكل في الاستقرار منذ ذلك الحين.في السابق كنا نستخدم موصل COM، الذي أظهر فشلًا منتظمًا في الاتصال (ربما مشكلة في تجميع الاتصال؟) وكان من الصعب تثبيته وتكوينه بشكل صحيح.

لقد واجهنا مشكلات عندما حاولنا استخدام المعاملات، ولكن إذا كنت تقوم بإجراء استدعاءات وظيفة عمل واحدة بسيطة، فلا ينبغي أن يمثل ذلك مشكلة.

تحديث: لتوضيح مشكلات المعاملات - إذا كنت تحاول الاحتفاظ بمعاملة ما عبر مكالمات متعددة، وكان خادم تطبيق JDE يتعامل مع عدد متواضع من المكالمات المتزامنة، فستبدأ مكالمات xmlinterop في عرض رسالة "فشلت استجابة XML" وقاعدة البيانات يتم ترك المعاملة مفتوحة دون أي وسيلة للالتزام أو التراجع.من الممكن أن يؤدي التغيير والتبديل في عدد النوى إلى حل هذه المشكلة، ولكن شخصيًا، سأحاول دائمًا إكمال المعاملة في مكالمة واحدة.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top