Consume Business Service in .NET

AlexRO

AlexRO

Well Known Member
Hello all,

I'm trying to consume a simple service in .Net and I can not get the correct response. I have successfully deploy my BSSV Server on WLS, enable SSL and tested it with SOAPUI and it works.

After that I have created a simple .net project setup my web reference. In order to insert the custom soap header i have created an soap extension. But I get

[ QUOTE ]
SOAP header Security was not undestood

[/ QUOTE ]

When I looked at the return stream it is the exact string returned by SOAP ui. Any info will be of great help.

Thanx,
Alex.
 
After some research I have finally managed to consume my service.

Here is what I've done:

-Added Microsoft.web.services3.dll reference
-Modified the generated proxy to derive from Microsoft.web.services3.WebServicesClientProtocol instead of System.Web.Services.Protocols.SoapHttpClientProtocol
-Add a UsernameToken to the SoapContext of the Proxy.

and that's it.

Hope someone will find this useful.

Cheers,
Alex.
 
Hello Alex,

I am having the same scenario. Trying to call business service deployed to WAS bssv server from a .NET web application.
I don't know how to change the soap header. kindly can you provide me with the steps required to call a JDE service from a .NET project. and how to include the user name and password in the SOAP message.

Thanks
Anan
 
I know this thread is old, but I just had the same problem and searched some time until I found it, so here is the answer:
The webreferences in Visual studio creates a "Reference.cs" in which you have to change the line
"public partial class RI_AddressBookManager : System.Web.Services.Protocols.SoapHttpClientProtocol {"
into
"public partial class RI_AddressBookManager : Microsoft.Web.Services2.WebServicesClientProtocol {"

After this a c# code like this should work:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using webserviceJDE.AddressBookManager; //the webreference
using System.Web.Services;
using Microsoft.Web.Services2.Security.Tokens; //Microsoft WSE 2.0 SP2
using System.Net;


namespace webserviceJDE
{
class Program
{
static void Main(string[] args)
{
string username = "jde";
string password = "jde";
UsernameToken ut = new UsernameToken(username, password, PasswordOption.SendPlainText); //Create Security token...

RI_AddressBookManager abm = new RI_AddressBookManager();//RI_AddressBookManager();
NetworkCredential myCred = new NetworkCredential(username, password);
abm.RequestSoapContext.Security.Tokens.Add(ut);
RI_GetAddressBook a = new RI_GetAddressBook();//Selection Parameters
a.entityTypeCode = "E"; //just look for employees
RI_ShowAddressBook S = abm.getAddressBook(a);
if (S != null)
{
foreach (RI_AddressBook ab in S.addressBook)
{
Console.WriteLine(ab.entityName);
}
}


}
}
}

Thanks go to Carsten in Thread#143808 who uploaded a "HowTo call secured JDE WebServices using jdeveloper or MS
VS2005"

Hope that will help others to save some time...

Regards,
Florian
 
additional hint:
when using SSL (https://) to contact the webservice, you have to add two lines of code before calling the wenservice:
abm.Url = "http<font color="red">s </font>://<server>/webservicename";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

The first changes from http to https and the second changes the protocol from TLS to SSL3 which is used by JAVA-based webservices.
Unfortunately I could not find a way how to add the webreference using https because VisualStudio 2010 (and versions before) seem to have no option to change the security protocol.
 
Does anyone have a fully-operational example of consuming a business service in .NET/C#/VS2010? It would seem that many of the suggestions in this thread are no longer applicable as VS2010 does not support WSE (any version).

I have access to the WSDL and have setup a "service reference" within the VS2010 solution/project, but it is not operational at all. I assume it has something to do with authentication, but...?

Thanks in advance for any assistance!

Lynn
 
Hi,
I have tested the code below but the error message that I keep getting is "can not connect to remote server".

Any advice?




End Sub

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim username As String = "jde"
Dim password As String = "jde"
Dim ut As New UsernameToken(username, password, PasswordOption.SendPlainText)
' Create Security token...
Dim abm As New RI_AddressBookManager()
abm.RequestSoapContext.Security.Tokens.Add(ut)
Dim a As New RI_GetAddressBook()
'Selection Parameters
a.entityTypeCode = "C"
'just look for customers
Dim en As New RI_Entity()
en.entityId = 1145
'select Customer 1145
a.entity = en
textBox1.Text = ""
textBox2.Text = "Calling Webservice..."
' textBox2.Refresh()
Try
Dim S As RI_ShowAddressBook = abm.getAddressBook(a)
If S IsNot Nothing Then
For Each ab As RI_AddressBook In S.addressBook
TextBox1.Text += ab.EntityName & "; "
Next
End If
TextBox2.Text = "Success!"
Catch ex As Exception
TextBox2.Text = (ex.Message & vbLf & vbLf) + ex.StackTrace
End Try
End Sub

End ClassImports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Web.Services.Protocols
'Imports webserviceJDE '.AddressBookManager
Imports System.Web.Services
Imports Microsoft.Web.Services3.Security.Tokens
Imports Microsoft.Web.Services3
'Imports wse_Test.RI_AB.RI_AddressBookManagerHttpPortClient


Imports System.Net
Imports wse_Test.RI_AB


Public Class _Default
Inherits System.Web.UI.Page

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


Dim username As String = "jde"
Dim password As String = "jde"
Dim ut As New UsernameToken(username, password, PasswordOption.SendPlainText) '; //Create Security token...

Dim abm As New RI_AddressBookManager() ';//RI_AddressBookManager();
Dim myCred As New NetworkCredential(username, password)

abm.RequestSoapContext.Security.Tokens.Add(ut)

Dim a As New RI_GetAddressBook() ';//Selection Parameters

a.EntityTypeCode = "E" '; //just look for employees
Dim S As RI_ShowAddressBook = abm.getAddressBook(a)
If (S.ToString <> "") Then

Dim ab As RI_AddressBook
' While (ab = S.AddressBook)

MsgBox(ab.EntityName)

' End While
End If

End Sub
End Class
 
Not sure about VS2010, but with VS2013, I was unable to fully create the web reference in my website -- it didn't generate the "reference.vb" file. To get around this I created a "Class Application" (aka DLL file). In this project, I was able to successfully generate the web references with the "reference.vb" file, and then alter the "reference.vb" file with Microsoft.Web.Services2 as mentioned in previous posts.

After building this project (which creates a DLL), I imported the DLL into my website project.

I'm getting a few other errors now when making calls, but it looks like I made it past step 1
smile.gif



-Randy
 
Hi all,

This is my first post to the community so please be kind :)

I was tasked to create a .NET client to consume these WSDLs:
//http://xxx.x.x.xxx:yyyy/DV910/AddressBookManager?wsdl
//http://xxx.x.x.xxx:yyyy/DV910/CustomerManager?wsdl

I have scoured the usual online resources and could not find any helpful/current examples for Visual Studio 2015 C#.
Here are some links that I did find but are not useful as they are too old (VS2005!) or rely on JDE specific tools.

o http://sofb.developer-works.com/art...unicate+with+this+JDE+(JD+Edward)+Web+service
o https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=jde bssv vs2015

Should this be a WCF, WebAPI, or standard Class Library project?

I have added the "Web Reference" to a Class Library (Add Service Ref->Advanced->Add Web Ref) but am stuck with simple things like how to create an ICredentials object to log in - and after that ?????

I have created a WCF but am drowned out by the amount of coding overhead (first WCF for ME!!) and have lost track of the forest through the trees

What I'm really looking for is documentation of a shell project that:
1) adds the JDE WSDL web reference (URL)
2) gives an example for connecting to the service (login/auth)
3) calls a method on the jde object (getCustomerV2) with a parameter
4) process the result in some sort of meaningful way

here is an example of the type of code I'm loooking for ... just for VS2015 (the following code uses Microsoft WSE 2.0 SP2 which is not current)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using JDEWebService.JDE_AddBookMgr_WebReference; //the webreference
using System.Web.Services;
using Microsoft.Web.Services2.Security.Tokens; //Microsoft WSE 2.0 SP2
using System.Net;




namespace webserviceJDE
{
class Program
{
static void Main(string[] args)
{
string username = "jde";
string password = "jde";
UsernameToken ut = new UsernameToken(username, password, PasswordOption.SendPlainText); //Create Security token...


RI_AddressBookManager abm = new RI_AddressBookManager();//RI_AddressBookManager();
NetworkCredential myCred = new NetworkCredential(username, password);
abm.RequestSoapContext.Security.Tokens.Add(ut);
RI_GetAddressBook a = new RI_GetAddressBook();//Selection Parameters
a.entityTypeCode = "E"; //just look for employees
RI_ShowAddressBook S = abm.getAddressBook(a);
if (S != null)
{
foreach (RI_AddressBook ab in S.addressBook)
{
Console.WriteLine(ab.entityName);
}
}




}
}
}

Here is my attempt:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using JDEWebService.JDE_CustMgr_WebReference;
using JDEWebService.Properties;


namespace JDEWebService
{
public class JDEWebService
{
public string TEST()
{
ICredentials credentials = new NetworkCredential("JDEWBSRVC", "BSSV42#T");
getCustomerV2 customer = new getCustomerV2();


using (CustomerManagerService service = new CustomerManagerService())
{
service.Credentials = credentials;
service.getCustomerV2(customer);
}
return "done";
}


}
}

Any and all suggestions would be greatly appreciated.
ty - marcus
 
Hi - were you able do this? I am trying to do the same in VB.net. VS2015 and JDE9.1.5.2 Appreciate your help.
 
Last edited:
Hi Guys, anyone able to do this? I am getting the following error:

Could not create SSL/TLS secure channel.



at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at Microsoft.Web.Services2.WebServicesClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at WindowsFormsApp2.WebReference.AddressBookManager.getAddressBook(GetAddressBook getAddressBookElement) in c:\users\edwardkch\documents\visual studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Web References\WebReference\Reference.cs:line 270
at WindowsFormsApp2.Form1.button1_Click(Object sender, EventArgs e) in c:\users\edwardkch\documents\visual studio 2017\Projects\WindowsFormsApp2\WindowsFormsApp2\Form1.cs:line 56


Thanks.
 
Hey nkuebelbak,

Any idea how to do it? i am totally new to this.

Thanks.
 
need some jde info. weblogic or websphere. tools release? helps to have that kinda info in your signature
 
Hello All,
Please have a look at this code extract, this might be helpful.
In short this function calls SalesOrderManager.processSalesOrderV4 BSSV.
This is working on JDE 9.1, Visual Studio 2013 (SQL Server Integration Services).

Code:
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
        binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
        binding.MaxBufferSize = 2147483647;
        binding.MaxBufferPoolSize = 2147483647;
        binding.MaxReceivedMessageSize = 2147483647;
        EndpointAddress url_SalesOrderManager = new EndpointAddress(this.Variables.JDEBSSVServerURL + "SalesOrderManager");
        Oracle_E1_SBF_JWS_PkgBldFile_SalesOrderManagerClient client = null;

Code:
        try
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender1, certificate, chain, sslPolicyErrors) => true);
        }
        catch (Exception ex)
        {
            blnDontExe = true;
            strException = ex.ToString();
            strErrors = "Error overriding the server certificate validation";
        }


Code:
  public void ProcessJDECreateSalesOrder(SalesOrderImportType order, ProcessSalesOrderV4 request, out ConfirmSalesOrderV4 response)
    {
        response = null;
        string strErrors = "";
        string strException = "";
        bool blnDontExe = false;

        BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
        binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
        binding.MaxBufferSize = 2147483647;
        binding.MaxBufferPoolSize = 2147483647;
        binding.MaxReceivedMessageSize = 2147483647;
        EndpointAddress url_SalesOrderManager = new EndpointAddress(this.Variables.JDEBSSVServerURL + "SalesOrderManager");
        Oracle_E1_SBF_JWS_PkgBldFile_SalesOrderManagerClient client = null;

        try
        {
            client = new Oracle_E1_SBF_JWS_PkgBldFile_SalesOrderManagerClient(binding, url_SalesOrderManager);
        }
        catch (System.InvalidOperationException ex)
        {
            strException = ex.ToString();
            strErrors = ex.ToString();
        }
        catch (System.UriFormatException ex)
        {
            strException = ex.ToString();
            strErrors = ex.ToString();
        }
        if (client == null)
        {
            blnDontExe = true;
        }

        try
        {
            client.ClientCredentials.UserName.UserName = this.Variables.JDEBSSVServerUserName;
            client.ClientCredentials.UserName.Password = this.Variables.JDEBSSVServerPassword;
            BindingElementCollection elements = client.Endpoint.Binding.CreateBindingElements();
            elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
            client.Endpoint.Binding = new CustomBinding(elements);
            client.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0);
        }
        catch (System.InvalidOperationException ex)
        {
            strException = ex.ToString();
            strErrors = ex.ToString();
        }
        catch (System.UriFormatException ex)
        {
            strException = ex.ToString();
            strErrors = ex.ToString();
        }
        if (client == null)
        {
            blnDontExe = true;
        }

        try
        {
            System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender1, certificate, chain, sslPolicyErrors) => true);
        }
        catch (Exception ex)
        {
            blnDontExe = true;
            strException = ex.ToString();
            strErrors = "Error overriding the server certificate validation";
        }
        if (blnDontExe == false)
        {
            try
            {
                response = client.processSalesOrderV4(request);

                LogMessage(this.Variables.JDEConnectionString, this.Variables.InterfaceID, order.CustomerOrderID + ", processSalesOrderV4.request", guid.ToString(), "", "", "", ConvertToXML(request));
                LogMessage(this.Variables.JDEConnectionString, this.Variables.InterfaceID, order.CustomerOrderID + ", processSalesOrderV4.response", guid.ToString(), "", "", "", ConvertToXML(response));
            }
            catch (Exception ex)
            {
                strErrors = "Error " + ex.Message + "\n\n" + ex.StackTrace;
                strException = ex.ToString();
            }
        }

        if (!strException.Equals(string.Empty))
        {
            AddNotification(order, request.Header.CustomerPO, this.Variables.InterfaceID, "Process_" + order.ediConfig.CompanyKey, "JDE - EDI (" + order.ediConfig.CompanyKey + ") Interface: Error found in PO # " + order.CustomerOrderID + " from " + order.ediConfig.ShipToAlph, strErrors + "<hr>", "1", "");
            LogMessage(this.Variables.JDEConnectionString, this.Variables.InterfaceID, order.CustomerOrderID + ", processSalesOrderV4.exception", guid.ToString(), "", "", "", ConvertToXML(strException));
        }
        else
        {
        }
    }
 
Back
Top