Pregunta

Me pregunto si alguien tiene éxito en el uso de la funcionalidad XMLInterop de JDEdwards.Lo he estado usando por un tiempo (con un PInvoke simple, publicaré el código más adelante).Estoy buscando para ver si hay una manera mejor y/o más sólida.

Gracias.

¿Fue útil?

Solución

Como prometí, aquí está el código para la integración con JDEdewards usando XML.Es un servicio web, pero puede usarse como mejor le parezca.

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;
    }
}

}

Tienes que enviarle mensajes como el siguiente:

<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>

Otros consejos

Para cualquiera que intente hacer esto, existen algunas dependencias de xmlinterop.dll.

Encontrará estos archivos en el cliente pesado aquí ->c:\E910\system\bin32

esto creará un 'cliente ligero'

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

Cambié nuestro servicio web JDE para usar XML Interop después de ver este código y no hemos tenido ningún problema de estabilidad desde entonces.Anteriormente estábamos usando el conector COM, que presentaba fallas de comunicación regulares (¿posiblemente un problema de agrupación de conexiones?) y era complicado instalarlo y configurarlo correctamente.

Tuvimos problemas cuando intentamos utilizar transacciones, pero si realiza llamadas simples a funciones comerciales únicas, esto no debería ser un problema.

Actualizar: Para profundizar en los problemas de transacción, si está intentando mantener activa una transacción a través de múltiples llamadas, Y el servidor de aplicaciones JDE está manejando una cantidad modesta de llamadas simultáneas, las llamadas xmlinterop comienzan a devolver un mensaje de "respuesta XML fallida" y la base de datos La transacción se deja abierta y no hay forma de confirmarla o revertirla.Es posible que ajustar la cantidad de núcleos pueda resolver esto, pero personalmente, siempre intento completar la transacción en una sola llamada.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top