This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I want to send back entire request which come previously as a response.

var id=sv.GetOrCreate(x => x.Request.JSONRequest).requestId;

sv.Contexts.Server.Add(id,sv.Request.ToJson());
sv.Response.SetFromJson(sv.Contexts.Server[id].ToString());
var s=(string)sv.Contexts.Server[id];
sv.MessageLogger.Warn(s.GetType());
// HttpContent httpContent = new StringContent(s);
sv.MessageLogger.Warn("req"+sv.Request.ToJson());
sv.MessageLogger.Warn(sv.Contexts.Server[id].ToString());

}

Any Issue with this code? Getting Error
Internal server error\nC# rule Scripted Rule 1 execution failed on line 294 with error InvalidOperationException: Failed to set value on 'UriPath' on path 'Proxied [response], [path: ]'\n at HP.SV.Runtime.Simulation.DataSimulator.CSharp.DotNetServiceOperationRuleNetRuleExecutor.Execute(IServiceOperationScriptedRule scriptedRule, IScriptObject request, IScriptObject response, IAdditionalPropertiesObject additionalProperties, IScriptServiceCallActivity[] serviceCallActivities, IScriptContext context, IScriptObject environment, IScriptObject serviceInfo, IDictionary`2 requestMetadata) in Y:\SV5.4.0.2710-S-c0608d23\net\Runtime\Simulation\DataSimulatorCSharp\DotNetServiceOperationRuleNetRuleExecutor.cs:line 203

  • Verified Answer

    +1

    FromJSON() should be executed on the same node as was previously executed ToJSON() otherwise structure might not match and you'll get errors. In your case it cannot find "UriPath" on the response node as it is present only in the request.

    If the message structure is the same below certain level, you can try to copy just that part. Or you can try to switch to Binary/HTTP, which is unstructured.

  • 0 in reply to 

    Can you share some example to copy just a part from request?

  • 0 in reply to 

    Just navigate to sume sub-node using dot notation like an example below:

    sv.Request.Envelope.Body.memberSearch.name.ToJson();