Extensis Logo SUPPORT | FORUMS | KNOWLEDGE BASE

Connection to Portfolio 2016 using SOAP and C#


#1

Hi
I am using C# 2013 and the Portfolio SOAP API to connect to Portfolio 2016 but get the error “The server committed a protocol violation. Section=ResponseStatusLine” when I attempt to get a RSA key with the call keySpecification key = service.getRSAPublicEncryptionKey();

code snippet :-
AssetSEIService service = new AssetSEIService();
service.Url = “http://xxxxxxxxx:8090/ws/1.0/AssetService”;

try
{
        // Use getRSAPublicEncryptionKey to get the necessary Key for encrypting the password.
   keySpecification key = service.getRSAPublicEncryptionKey();
 }
catch (Exception ex)
{
  Console.WriteLine(ex.Message);
  return;
}

The error occurs for all target framework versions 2.0, 3.5 and 4.5.1. Calls from this program to other non-Portfolio SOAP web services on our estate are working fine.

Also, a call to the portfolio api method getRSAPublicEncryptionKey method works fine through SoapSonar, and returns the following :-

<?xml version="1.0" encoding="UTF-8"?>

<S:Envelope xmlns:S=“http://schemas.xmlsoap.org/soap/envelope/”>
<S:Body>
<ns2:getRSAPublicEncryptionKeyResponse xmlns:ns2=“http://portfolio.extensis/service/asset”>

65537
ad19ae39f3c2e7e8737591e2b8e5f181d2adb8272a6d2896f84ef66586f1cc341a2d749110da6c6d1439cbb11b4aa783f080d3821f09148b2b3c407f5ed31404245c073b7b3c4b9378e40ac339c4a9969eef6dfbe7c5903ddf8764c422b6cf03e4ca4d0f190b6124e207fb60a630a405ae703259c60d0aecf80a33bbf1c14ddde50c8df1ac8ad9c4a63ad6917cac25b19a5c1444e92fa840dfe9e06170d16ef435ba3655bef41cc08e9f12dd86c78a7aa7ad0c066a10f961df69ee2c21df5c6fc67268fbaf1f12959f487ec97ae1ba9cbb384a96de1bd29420abf2873cfaf6f01297e7844b5a4a321f770f057a89e6b01c5f3b61a4f7a5a3ca8c37f5dfdfd483

</ns2:getRSAPublicEncryptionKeyResponse>
</S:Body>
</S:Envelope>

which suggests our portfolio 2016 installation is OK.

What am I missing? Please help.


#2

Hi Gordon,

We have not run into this problem. Since you are able to retrieve the RSA key using SoapSonar, that likely indicates something needs to be changed in your C# client code.

Googling for the error you see returned a lot of hits, so I would start there. For instance this page: webmonkeys.org.uk/2012/09/c- … tatusline/

On that page, the author recommends including the line:

request.KeepAlive = false;

and/or

request.ServicePoint.Expect100Continue = false;

and/or this in your app.config:
<system.net>



</system.net>

Now, we have not tested using those, but personally I would try each of those in turn and see if that fixes the problem.

Please let us know the results, if you are still blocked on this we can help debug further.

Best wishes,
-Loren


#3

Hi Loren
I had looked at this page prior to logging my call with you. I do have useUnsafeHeaderParsing=“true” in the clients app.config; but the advice given for keepalive suggests setting keepalive=false on a web request call, i am using a SOAP call as per your sample code and this property is not exposed on a SOAPHttpClientProtocol object. So i am not clear how i can set the suggested properties in client-side code.But I will keep digging.

.

I have looked server side, specifically at how to configure JBOSS and Apache to set keepalives = false but cant find out where to set the maxKeepAliveRequests to 1 to disable keep-alives (as described in docs.jboss.org/jbossweb/2.1.x/config/http.html)

I did look to set it in the C:\Program Files (x86)\Extensis\Portfolio Server\applications\tomcat\servers\admin\conf\server.xml file but this does not define a connector for port 8090.

Any ideas how to set keep-alives off on the server side?
Our server is Windows Server 2012 r2 if that helps,

Cheers
Gordon


#4

fixed it!
I need to set theExpect100Continue flag to false. This can be done in a SOAP call in C# by editing the autogenerated code
in AssetSEIService.cs (provided with your code samples) and overriding GetWebRequest as shown below:-

public partial class AssetSEIService : System.Web.Services.Protocols.SoapHttpClientProtocol {

protected override WebRequest GetWebRequest(Uri uri)
{
    WebRequest request = base.GetWebRequest(uri);
    HttpWebRequest request2 = request as HttpWebRequest;
    //request2.KeepAlive = false; // does not work, causes the connection to fail
    request2.ServicePoint.Expect100Continue = false; // THIS WORKS!!!
               

    return request2;
}

Rest of auto generated code unchanged.


#5

Excellent! That’s great to hear, and really good to know for future 3rd party integrators who want to use a C# and SOAP stack.

Cheers,
-Loren


#6

I started getting the same error when we updated from v2.0.2 to v2.5.3. I tried to implement the above solution for our code, but am not having any success. Using “request2.KeepAlive = false;” results in the same error, using “request2.ServicePoint.Expect100Continue = false;” results in the error:

; nested exception is: extensis.esp.exception.InvalidCredentialsException
; nested exception is: extensis.esp.exception.InvalidCredentialsException
; nested exception is: extensis.esp.exception.InvalidCredentialsException

I have very little C# background, so any help would be greatly appreciated. Thank you!

EDIT: In troubleshooting the error, I found that the problem seems to be associated with using an encrypted catalog password variable. When I modify the code to use the unencrypted password, the connection is successful. I’m going to start a new thread since this is an entirely different issue.


#7

OK, thanks Gordon.