Delphi Loginservice Sample and Soap Service

Hi,

I’m using the LoginSerice in a Delphi application the same as in the for example Super TCP Channel chat example.

When I want to use the service as a plain soap service from .NET, this code dos not work since my service has no access to the session of the Login Service. How can I make hat happen?

Thank,

Sample:

private static void testSoap()
{
LoginService.LoginServiceClient lsc = new LoginServiceClient(); lsc = {LoginServiceClient}
bool LoggedIn = lsc.Login(‘mypass’,‘myuser’); loggedin = true
if (LoggedIn)
{
MyService.MyServiceClient msc = new MyServiceClient();
msc.DoSomething -> Now the call has no access to the session variables of the loginservice.
}
}

Hello

Server expects session Id to be passed via SOAP message headers.

F.e. for Document requests it would look like

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:HNS="http://tempuri.org/" 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header>
        <ROClientIDHeader SOAP-ENV:mustUnderstand="0" xmlns="http://tempuri.org/">
           <ID>{ABCDEF12-3456-7890-1111-234567890123}</ID>
        </ROClientIDHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body xmlns:ro="#############">
      #############################################
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

You need to enable the xsoClientIdInWsdl option in your server app to let it expose required message headers in the WSDL.

After thant you need to generate some random Guid using the Guid.NewGuid() all and to use this guid in all server requests, including login service call

Hope that helps

Hi,

Yest that helps we’re able to access the service now. One more question, is it possible to remove the IsRequired= True value for Objects since in some cases c# does not like an empty object? And is it possible to remove the Order=x?

Hi, Any update on this?

Could you elaborate a bit what exactly do you mean here?

Hi,

Ok:

I have a struct say TMyStruct.
In teh implementation I initialize the struct althout its emoty like:

MyStruct := TMyStruct.Create;

In VS / C# plain soap the output generated shows the following:

We’d like to remove the IsRequired and also remove the Order tag. Is that possible?

Thanks,

This code is auto-generated by VS web service import tool based on the WSDL exposed by the server.
AFAIK the Order part cannot be removed at all.
The IsRequired is based on WSDL attributes, so if possible cleate a simple testcase (literally a server with 2 structures and C# client) where this reproduces.

Also I need to mention that Remoting SDK servers provide a feature called HttpAPI. This feature turns them into REST servers that expose Swagger/OpenAPI compatible metadata (so client code can be generated for pretty much any language, from C# or Java to Python or JS). In come cases this might be a better communication option than SOAP.

Here is a sample project in Delphi:

ROSampleClient.dproj.zip (117.6 KB)

Which generates this:

image

From our VS developer:
The selected type member doesn’t have minOccurs and maxOccurs elements. It means that this element is required and it’s position is fixed. We want to make an element optional. It should be minOccurs=0 maxOccurs=1.

So in this case when we assign blank values for Name and Contact, VS will raise an error.

Second question for Enum values they are shown as text and not numerical values. Can we adjust this?

image

Hi,

for generation of minOccurs=0 maxOccurs=1, you should declare a new struct in Service Builder like

<Struct Name="AnsiString_Anonymous" UID="{...}" AutoCreateParams="1">
  <CustomAttributes>
      <anonymous Value="1" /> 
  </CustomAttributes>
  <Elements>
    <Element Name="Value" DataType="AnsiString" /> 
  </Elements>
</Struct>

and use it for Name parameter:

after this, wsdl will contain

the same for Person parameter

try to declare that parameter as integer instead of enum. all enums are written as string, like

<Sex xsi:type="ro:TSex">sxMale</Sex

Hi,

Thanks. I have added the anonimous=1 in the Custom Attibutes Editor of my servcie library but that did not change anything in the output.

Or should I just add the MinOccurs and MaxOccurs in the custom attributes?

Thanks,

Hi,
generation of MinOccurs and MaxOccurs is possible only on struct and arrays, so you should create wrapper struct for your field.

check RODL: NewLibrary.RODL (1.9 KB)

Hi,

In the attached I have marked the Contact of the company with custom attribute anonymous=1 but ti does not geenrate the minoccurs and maxoccurs.

NewLibrary.RODL (2.0 KB)

Hi,
it should be declared in the same way as AnsiStruct_Anonymous struct: NewLibrary.RODL (2.2 KB)

Thanks but this means I have to re work the enbire library to make it compatible with Soap. There is no other way?

Hi,

we have only one way for autogenerating such things.
ofc, you can manually adjust generated WSDL and modify it as you want …

Hello,

Is there an example on how to modify the WSDL for this scenario?