XML-String of Request and Response from application side

Deals with generic topics such as logging, framework and so on. If you are not sure where to place your topic just put it here.
Post Reply
Lauterfeld
Posts: 26
Joined: Tue Apr 14, 2015 1:19 pm

XML-String of Request and Response from application side

Post by Lauterfeld »

Hi together,

I'm interested in getting the XML-Strings of request and response from application side - only for xTour 1.x.

We log the XMLs already in the server side file provided bei PTV.

But the users in our application has no chance to analyse them. So I'm looking for a possibility to get the XMLs out of the API when sending the request and when getting the response. Ist that possible?

We communicate with xTour out of an oracle database using the embedded java in a 'very' old version. I don't find a method in the classes provided by the WSDL and PTV.

Kind regards,
Volker
Volker Lauterfeld
Software-Entwicklung und Projekte
COS GmbH
Gesellschaft für Computersysteme,
Organisation und Softwareentwicklung mbH
Raiffeisenstraße 21
D-77704 Oberkirch
http://www.cosonline.de/
daxbin
Posts: 13
Joined: Thu Feb 16, 2017 2:03 pm

Fiddler – Free Web Debugging Proxy to Log Network Traffic

Post by daxbin »

Hello Volker,

I had a similar problem some time ago. My idea was to log all traffic between client and server with an additional proxy in between. Fortunately, my problem has been solved in a different way. So, in lack of own experience I can't recommend you a specific tool.

Anyway, I had already downloaded a Windows tool named Fiddler. It would have been the tool, which I would have tried first.

You can get it from or from german software sites too: Sure, there are also a lot of other suitable tools.

Just an idea, best regards, Birk
User avatar
Bernd Welter
Site Admin
Posts: 2546
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: XML-String of Request and Response from application side

Post by Bernd Welter »

Hello Volker,

that's a difficult question and the answer depends on the client libraries that are in use. I assume that the FIDDLER approach mentioned in daxbin's answer is not exactly what you'd like to do, right?

As this topic deals more with language / framework specific capabilities I redirect you to a standard search in the web.

E.g. looking for JAVA I immediately found this:
http://stackoverflow.com/questions/1945 ... ith-jax-ws

I'll forward your request to our developers, maybe someone of them can give more detailed hints.

Which framework do you use?

Best regards Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at Youtube
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 2546
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: XML-String of Request and Response from application side

Post by Bernd Welter »

Hello Volker,

here are some c# code snippets for xMap demonstrating how to serialize requests on client side. (Thanks to Mathias for the sample!)

Just wrap the request objects:

Code: Select all

//
    // The following classes are wrappers for the SOAP elements and the xMap service methods
    // renderMap and renderMapBoundingBox which are used only for (de)serialization to and from XML.
    // They use the auto generated classes from the WSDL file.
    //
    [System.Serializable()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.xmlsoap.org/soap/envelope/")]
    public class Body
    {
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://types.xmap.xserver.ptvag.com")]
        public renderMapRot renderMapRot;

        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://types.xmap.xserver.ptvag.com")]
        public renderMapBoundingBox renderMapBoundingBox;

        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://types.xmap.xserver.ptvag.com")]
        public renderMap renderMap;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.xmlsoap.org/soap/envelope/")]
    public class BodyRM
    {
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://types.xmap.xserver.ptvag.com")]
        public renderMap renderMap;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.xmlsoap.org/soap/envelope/")]
    public class BodyRMBB
    {
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://types.xmap.xserver.ptvag.com")]
        public renderMapBoundingBox renderMapBoundingBox;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.xmlsoap.org/soap/envelope/")]
    public class BodyRMR
    {
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true, Namespace="http://types.xmap.xserver.ptvag.com")]
        public renderMapRot renderMapRot;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlRootAttribute("Envelope", Namespace="http://schemas.xmlsoap.org/soap/envelope/", IsNullable=false)]
    public class Envelope
    {
        public Body Body;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlRootAttribute("Envelope", Namespace="http://schemas.xmlsoap.org/soap/envelope/", IsNullable=false)]
    public class EnvelopeRM
    {
        public BodyRM Body;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlRootAttribute("Envelope", Namespace="http://schemas.xmlsoap.org/soap/envelope/", IsNullable=false)]
    public class EnvelopeRMBB
    {
        public BodyRMBB Body;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlRootAttribute("Envelope", Namespace="http://schemas.xmlsoap.org/soap/envelope/", IsNullable=false)]
    public class EnvelopeRMR
    {
        public BodyRMR Body;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://types.xmap.xserver.ptvag.com")]
    public class renderMapRot : TransientVO
    {
        public MapSectionRot MapSectionRot_1;

        public MapParams MapParams_2;
        
        public ImageInfo ImageInfo_3;
        
        [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)]
        [System.Xml.Serialization.XmlArrayItemAttribute(Namespace="http://xmap.xserver.ptvag.com")]
        public Layer[] ArrayOfLayer_4;
        
        public bool boolean_5;
        
        public CallerContext CallerContext_6;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://types.xmap.xserver.ptvag.com")]
    public class renderMapBoundingBox : TransientVO
    {
        public BoundingBox BoundingBox_1;

        public MapParams MapParams_2;
        
        public ImageInfo ImageInfo_3;
        
        [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)]
        [System.Xml.Serialization.XmlArrayItemAttribute(Namespace="http://xmap.xserver.ptvag.com")]
        public Layer[] ArrayOfLayer_4;
        
        public bool boolean_5;
        
        public CallerContext CallerContext_6;
    }

    [System.Serializable()]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://types.xmap.xserver.ptvag.com")]
    public class renderMap : TransientVO
    {
        public MapSection MapSection_1;

        public MapParams MapParams_2;
        
        public ImageInfo ImageInfo_3;
        
        [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)]
        [System.Xml.Serialization.XmlArrayItemAttribute(Namespace="http://xmap.xserver.ptvag.com")]
        public Layer[] ArrayOfLayer_4;
        
        public bool boolean_5;
        
        public CallerContext CallerContext_6;
    }
Now you can serialize your request object and write it to a file:

Code: Select all

MapSection mapSection = new MapSection();
BoundingBox boundingBox = new BoundingBox();
MapParams mapParams = new MapParams();
ImageInfo imageInfo = new ImageInfo();
Layer[] arrayOfLayer = null;
CallerContext callerContext = new CallerContext();

// FIXME fill the request object

XmlSerializer formatter = new XmlSerializer(typeof(EnvelopeRMBB));

EnvelopeRMBB env = new EnvelopeRMBB();
env.Body = new BodyRMBB();
env.Body.renderMapBoundingBox = new renderMapBoundingBox();
env.Body.renderMapBoundingBox.BoundingBox_1 = boundingBox;
env.Body.renderMapBoundingBox.MapParams_2 = mapParams;
env.Body.renderMapBoundingBox.ImageInfo_3 = imageInfo;
env.Body.renderMapBoundingBox.ArrayOfLayer_4 = arrayOfLayer;
env.Body.renderMapBoundingBox.boolean_5 = includeImageInResponse.Checked;
env.Body.renderMapBoundingBox.CallerContext_6 = callerContext;

// Open the file containing the data that you want to deserialize.
FileStream fs = new FileStream(sfd.FileName, FileMode.Create);
try 
{
    // Serialize the Soap envelope to the file
    formatter.Serialize(fs, env);
}
finally 
{
    fs.Close();
}
The result will be a valid xServer request.

Best regards Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at Youtube
I like the smell of PTV Developer in the morning... :twisted:
User avatar
MISTERX
Posts: 53
Joined: Mon Jun 02, 2014 11:50 am

Re: XML-String of Request and Response from application side

Post by MISTERX »

Hello Volker

I think we have talked about this personally just a fortnight ago - but I like to summarize for others viewing this thread.

As we know we have the possibility to log request and response by xServers itself. But this will not help during normal operation.

1. It's not wise to consume disc space on production systems by logging all/full communication
2. It needs experts to view xServer logs
3. It needs something like a unique key, known by your application, which we can find in the log files
4. xServer-API does not provide any method to ask for logged data
5. There is no possibility to turn logging on/off by request

Looking to the list above, I realized that the solution has to be on application site.

Depending to your surrounding (.COM, SQL or . . .) the number of tools in your box varies.

But independent from this, the only useful solution seems to be the "man-in-the-middle" (see other posts above).

That means, you have to get the request just when it was rendered (best will be binary). Furthermore you have to know information about the application context, like UID, URL of service/server you will call. I recommend to know meta data from use-case as well.

Assuming the request is rendered and you have meta-data, you have to write your own log instantly. As we are constantly working on/with DB/RDBMS it is keen to have in minimum own tables to store requests and meta-data.

Now you have only to wait for the xServer-response. Catch it (binary) and store it in your DB and don't forget a key, which refers to the appropriate request.

Sounds simple - is hard to realize. If your programming workbench offers you the creation of proxy simply by providing the URL to WSDL - and you have used this option in the past to connect your application to PTV-Services, you have to think about your approach. My experience is, that it is very helpful to have the request and response natively as they were sent/received AND the application data as they were in the moment of handing them over to the proxy. We are working with our framework (containing all the experiences gathered by numerous developers within almost ten years), proving all the functionalities which make the communication with xServer transparent and reliable.

Besides debugging, this offers a lot of possibilities to speed up development. By breaking the process and displaying request/response during runtime via shell command in an editor, you may alter request or response for tests etc. without development.

For sure you have to do the programming etc. - and I know it is a huge effort - but the result provides an enormous surplus / benefit.

My post might be a little bit unspecific - but there is no downloadable turn-key-solution in the web . . . and I'm some sort of white unicorn, sitting on an island called SAP

I'm with you . . .
Mr. X
  • Integration PTV <> SAP
  • Senior Consultant

________________________________________________

Optimism is only a lack of data!
User avatar
Bernd Welter
Site Admin
Posts: 2546
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: XML-String of Request and Response from application side

Post by Bernd Welter »

Hello Mr. X,

thanks for your feedback - just one more comment from my side:
Just in case you could need it: we return the ID that is also written in the xServer logs via the HEADER fields:
The response headers
The response headers
Maybe you can use those values to improve the gathering of information.

Best regards
Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at Youtube
I like the smell of PTV Developer in the morning... :twisted:
Post Reply