Ok now that the webservice is working, lets add two parameters (name and age) that we can pass to our webservice, go back and edit the code in Visual Studio.
Change this
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
namespace windows_noob_webservice
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://windows-noob.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[system.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
To this
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
namespace windows_noob_webservice
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://windows-noob.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[system.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string HelloWorld2(string name)
{
return "Hi " + name;
}
[WebMethod]
public string HelloWorld3(string name, string age)
{
return "Hi " + name + " your age is " + age;
}
}
}
Build the code (compile it) and you can simply copy the DLL found in bin to your webserver to test the new functions.
Copy the dll to the BIN folder of your current webservice on your server…
Copy the new web service operation to your CustomSettings.ini file and update your MDT Files package once done.
Once done, test the web service,
Click on HelloWorld3
Input some values into the fields:-
And click on Invoke, the result is ouput
Testing webservices from WinPE
We will now Create a WSF script file called helloworld.wsf, containing the following lines
<job id="MDTMenu_helloworld">
<script language="VBScript" src="..\ZTIUtility.vbs"/>
<script language="VBScript" src="..\ZTIDataAccess.vbs"/>
<script language="VBScript">
Dim oService
Dim oXML
oEnvironment.Item("testing") = Wscript.Arguments.Named.Item("helloworld")
Set oService = New WebService
oService.IniFile = "CustomSettings.ini"
oService.SectionName = "helloworld"
Set oXML = oService.Query
If oXML Is Nothing Then
oLogging.CreateEntry "Unable to call HelloWorld web service.", LogTypeWarning
WScript.Echo "Not Found" & vbcrlf
Else
oXML.setProperty "SelectionNamespaces", "xmlns:wn='http://windows-noob.com/'"
WScript.Echo oXML.SelectSingleNode("wn:string").Text
End If
</script>
</job>
Save it in the wnb subfolder of your MDT Files scripts directory. (eg: scripts\wnb)
Next create a new file called name_age.wsf, Paste in the following:-
<job id="MDTMenu_name">
<script language="VBScript" src="..\ZTIUtility.vbs"/>
<script language="VBScript" src="..\ZTIDataAccess.vbs"/>
<script language="VBScript">
Dim oService
Dim oXML
oEnvironment.Item("name") = Wscript.Arguments.Named.Item("name")
oEnvironment.Item("age") = Wscript.Arguments.Named.Item("age")
Set oService = New WebService
oService.IniFile = "CustomSettings.ini"
oService.SectionName = "helloworld3"
Set oXML = oService.Query
If oXML Is Nothing Then
oLogging.CreateEntry "Unable to call UserGetName web service.", LogTypeWarning
WScript.Echo "Not Found" & vbcrlf
Else oXML.setProperty "SelectionNamespaces", "xmlns:wn='http://windows-noob.com/'"
WScript.Echo oXML.SelectSingleNode("wn:string").Text
End If
</script>
</job>
Save the file and update your MDT files package on the distribution points.
Edit your CustomSettings.ini file, Add the following lines:-
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Adding paramters to a webservice.
Ok now that the webservice is working, lets add two parameters (name and age) that we can pass to our webservice, go back and edit the code in Visual Studio.
Change this
To this
Build the code (compile it) and you can simply copy the DLL found in bin to your webserver to test the new functions.
Copy the dll to the BIN folder of your current webservice on your server…
Copy the new web service operation to your CustomSettings.ini file and update your MDT Files package once done.
Once done, test the web service,
Click on HelloWorld3
Input some values into the fields:-
And click on Invoke, the result is ouput
Testing webservices from WinPE
We will now Create a WSF script file called helloworld.wsf, containing the following lines
Save it in the wnb subfolder of your MDT Files scripts directory. (eg: scripts\wnb)
Next create a new file called name_age.wsf, Paste in the following:-
Save the file and update your MDT files package on the distribution points.
Edit your CustomSettings.ini file, Add the following lines:-
PXE boot into WinPE, at your FrontEndHTA screen, press F8 to bring up a command prompt, cd to the following address
C:\_SMSTaskSequence\WDPackage\Scripts\wnb
And execute this:-
The following is output
In the screenshot above, UserDomain and UserID are actually the Network Access Account retrieved from SCCM.
(SCCMnaa) as defined in Computer Client Agent Properties.
Now lets test passing values to our Hello World3 operation in our webservice, Open a command prompt in WinPE and type this:-
C:
Then to execute the webservice try
We pass two properties to the web service, name and age, and the output is seen above.
Share this post
Link to post
Share on other sites