Skip to main content
1-Visitor
November 17, 2015
Solved

Unable to invoke SOAP request when needing to have a variable in the content information

  • November 17, 2015
  • 3 replies
  • 2168 views

Instead of hard coding <SystemName>844J</SystemName> something like <SystemName>myVariable</SystemName> should be used instead.

"<xml tag>"+ myVariable + " </XML tag>"  isn't accepted as a valid syntax.


var c1=

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">

<Body>

<ReadRecordMultipleValues xmlns="http://tempuri.org/">

<UserName>admin</UserName>

<Password></Password>

<GroupName></GroupName>

<ProjectName>844J Front End Loader</ProjectName>

<SystemName>844J</SystemName>

<Table>Problems</Table>;

<Identifier>Problem1</Identifier>

<!-- Optional -->

<FieldList>

<!-- Optional -->

<DataEngineField>

<FieldName>Problem Description</FieldName>

<TableName></TableName>

</DataEngineField>

<DataEngineField>

<FieldName>Owner of Problem</FieldName>

<TableName></TableName>

</DataEngineField>

<DataEngineField>

<FieldName>Action Taken</FieldName>

<TableName></TableName>

</DataEngineField> <DataEngineField>

<FieldName>Recommended Action</FieldName>

<TableName></TableName>

</DataEngineField>

<DataEngineField>

<FieldName>Problem #</FieldName>

<TableName></TableName>

</DataEngineField>

</FieldList>

</ReadRecordMultipleValues>

</Body>

</Envelope>;

var lengthC= String(c1).length;

logger.warn (" length "+ lengthC);

// var headers_action = new Object();

//headers_action.SOAPAction = "http://tempuri.org/ReadRecord";

//headers_actions.Content-Type="text/xml";

var headers={ "Content-Type": "text/xml","SOAPAction":"http://tempuri.org/ReadRecordMultipleValues"};

logger.warn ("HEADER"+ headers);

var params = {

headers: headers /* JSON */,

useProxy: undefined /* BOOLEAN */,

proxyHost: undefined /* STRING */,

useNTLM: undefined /* BOOLEAN */,

ignoreSSLErrors: true /* BOOLEAN */,

proxyPort: undefined /* INTEGER */,

withCookies: undefined /* BOOLEAN */,

password: undefined /* STRING */,

url: "http://icenterv01:81/PTCWindchillQualitySolutions10.2/DataEngine.asmx" /* STRING */,

workstation: undefined /* STRING */,

content: c1 /* XML */,

username: undefined /* STRING */,

proxyScheme: undefined /* STRING */,

domain: undefined /* STRING */,

timeout: 500 /* NUMBER */

};

var x=Resources["ContentLoaderFunctions"].PostXML(params);

Best answer by ptc-6292103

You can do like so:

var myVar="123";

var xml = <password>{myVar}</password>;

and then xml will store <password>123</password>

3 replies

avladescu1-VisitorAuthor
1-Visitor
November 17, 2015

if defining var myVar="123" and then passing it inside the xml tag like <Password>myVar</Password>  it will use myVar instead of "123" as value.

1-Visitor
November 17, 2015

not sure if this would work but

define the xml as string first so you can get the variable inserted properly using concatenation

then assign that string to an html variable, perhaps initially defined as var myxml = <xml></xml>