Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supply keepalive option for command/receive calls #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ private int receiveCommand(String commandId, Writer out, Writer err) {
stream.setCommandId(commandId);
stream.setValue("stdout stderr");
receive.setDesiredStream(stream);

final OptionSetType optSetCmd = new OptionSetType();
OptionType optKeepalive = new OptionType();
optKeepalive.setName("WSMAN_CMDSHELL_OPTION_KEEPALIVE");
optKeepalive.setValue("TRUE");
optSetCmd.getOption().add(optKeepalive);

try {
numberOfReceiveCalls++;
ReceiveResponse receiveResponse = winrm.receive(receive, WinRmClient.RESOURCE_URI, WinRmClient.MAX_ENVELOPER_SIZE, operationTimeout, locale, shellSelector);
ReceiveResponse receiveResponse = winrm.receive(receive, WinRmClient.RESOURCE_URI, WinRmClient.MAX_ENVELOPER_SIZE, operationTimeout, locale, shellSelector, optSetCmd);
getStreams(receiveResponse, out, err);

CommandStateType state = receiveResponse.getCommandState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public void delete(String resourceURI, int maxEnvelopeSize, String operationTime
}

@Override
public ReceiveResponse receive(Receive receive, String resourceURI, int maxEnvelopeSize, String operationTimeout, Locale locale, SelectorSetType selectorSet) {
RecordedCall call = new RecordedCall("receive", Arrays.asList(receive, resourceURI, maxEnvelopeSize, operationTimeout, locale, selectorSet));
public ReceiveResponse receive(Receive receive, String resourceURI, int maxEnvelopeSize, String operationTimeout, Locale locale, SelectorSetType selectorSet, OptionSetType optionSet) {
RecordedCall call = new RecordedCall("receive", Arrays.asList(receive, resourceURI, maxEnvelopeSize, operationTimeout, locale, selectorSet, optionSet));
calls.add(call);
return (ReceiveResponse) handler.apply(call);
}
Expand Down
6 changes: 6 additions & 0 deletions client/src/test/resources/recordings/win12.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@
xmlns:ns3="http://schemas.xmlsoap.org/ws/2004/09/transfer">
<ns2:Selector Name="ShellId">AF161CE1-3D3F-46B7-A101-800DD70639A9</ns2:Selector>
</ns2:SelectorSet>
<ns2:OptionSet
xmlns:ns1="http://schemas.microsoft.com/wbem/wsman/1/windows/shell"
xmlns:ns2="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
xmlns:ns3="http://schemas.xmlsoap.org/ws/2004/09/transfer">
<ns2:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">TRUE</ns2:Option>
</ns2:OptionSet>
</soap:Header>
<soap:Body>
<ns1:Receive
Expand Down
6 changes: 6 additions & 0 deletions client/src/test/resources/recordings/win7.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@
xmlns:ns3="http://schemas.xmlsoap.org/ws/2004/09/transfer">
<ns2:Selector Name="ShellId">DDAD7559-3B88-44FA-890B-7FD87F86CB6C</ns2:Selector>
</ns2:SelectorSet>
<ns2:OptionSet
xmlns:ns1="http://schemas.microsoft.com/wbem/wsman/1/windows/shell"
xmlns:ns2="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
xmlns:ns3="http://schemas.xmlsoap.org/ws/2004/09/transfer">
<ns2:Option Name="WSMAN_CMDSHELL_OPTION_KEEPALIVE">TRUE</ns2:Option>
</ns2:OptionSet>
</soap:Header>
<soap:Body>
<ns1:Receive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public ReceiveResponse receive(
@WebParam(name = "Locale", targetNamespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", header = true)
Locale locale,
@WebParam(name = "SelectorSet", targetNamespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", header = true)
SelectorSetType selectorSet
SelectorSetType selectorSet,
@WebParam(name = "OptionSet", targetNamespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", header = true)
OptionSetType optionSet
) {
return null;
}
Expand Down