Testing webservice with Bizunit

Nov 17, 2008 at 8:05 PM
Edited Nov 17, 2008 at 8:06 PM
Hi,

I am testing a webservice with bizunit here is my config file it looks like this.

I have a sample webservice which adds two numbers and gives us the result.

<?xml version="1.0" encoding="utf-8"?>
<TestCase testName="TestFile1_Test">
  <TestExecution>
<TestStep assemblyPath="" typeName="BizUnit.HttpRequestResponseStep">
    <SourcePath>C:\Users\amandav\Documents\Visual Studio 2008\Projects\AddingNumbersService\Service.xml</SourcePath>   
    <DestinationUrl>http://localhost/MyWebservices/Service1.asmx?op=AddingNumbers</DestinationUrl>
    <RequestTimeout>60000</RequestTimeout>
</TestStep>
  </TestExecution>
  <!-- Test cleanup: test cases should always leave the system in the state they found it -->
  <TestCleanup></TestCleanup>
</TestCase>

Here is my input xml file

<?xml version="1.0" encoding="utf-8"?>
 <AddingNumbers xmlns="http://localhost/AddingNumbersService">
      <a>23</a>
      <b>33</b>
 </AddingNumbers>


When I run the Nunit with the test project it gives me an error:

WebServiceTest.TestFileClass.TestFile1_Test:
System.Net.WebException : The remote server returned an error: (500) Internal Server Error.

Here is my test class:


[

TestFixture]

 

 

 

public class TestFileClass

 

 

{

 

[

Test]

 

 

 

public void TestFile1_Test()

 

{

 

BizUnit.

 

BizUnit bizUnit = new BizUnit.BizUnit(..\Documents\Visual Studio 2008\BizSampServiceTest.xml");

 

bizUnit.RunTest();

}

}

 




Can anyone help me out in this regarding. If some one can post an example for this that would be great

Note:  This webservice is non biztalk project(ordinary webservice)


Thanks
mandava29
Dec 13, 2008 at 1:25 PM
Hi,
HTTP 500 errors could mean different things, not necessarily a problem with BizUnit. Have you written a "normal" unit tests against the webservice, perhaps calling the proxy class directly to see if the service is in fact working?

Benjy
Sep 8, 2009 at 9:14 PM
Edited Sep 8, 2009 at 9:17 PM

I exposed my orchestration as a webservice and trying to test the webservice using bizunit SOAPHTTPRequestResponseStep.

 

here is my config xml

 

<TestCase testName="SampleTest">

<TestExecution>

  
 
 <TestStep assemblyPath="" typeName="BizUnit.SOAPHTTPRequestResponseStep">
 <WebServiceWSDLURL>http://localhost/KForce.Lookup_Proxy/KForce_Lookup_Orchestration_1_SOAPRequestRespPort.asmx?wsdl</WebServiceWSDLURL>
 <ServiceName>KForce_Lookup_Orchestration_1_SOAPRequestRespPort</ServiceName>
 <WebMethod>Operation_1</WebMethod>
 <InputMessageTypeName>KForce.Lookup.RequestSOAP_0x30f8b4a5.xsd</InputMessageTypeName>
 <MessagePayload>C:\Development\Kforcelookup.xml</MessagePayload>


    <ValidationStep assemblyPath="" typeName="BizUnit.XmlValidationStep">
        <XmlSchemaPath>C:\Development\KForce.Lookup\KForce.Lookup\ResponseSOAP.xsd</XmlSchemaPath>
        <XmlSchemaNameSpace>http://KForce.Lookup.ResponseSOAP</XmlSchemaNameSpace>
        <XPathList>
            <XPathValidation query="/*[local-name()='Root' and namespace-uri()='http://KForce.Lookup.ResponseSOAP']/*[local-name()='wtehours' and namespace-uri()='']">2009-01-07T00:00:00</XPathValidation>
        </XPathList>
    </ValidationStep>           
</TestStep>


</TestExecution>

<TestCleanup>

</TestCleanup>


 
</TestCase>

 

 

When I run it using nunit gui  it gives me the following error

System.TypeLoadException  Could not load type Bizunit.Proxy.KForce.Lookup.RequestSOAP_0x30f8b4a5.xsd from assemblt TestFrameWorkProxy0

<InputMessageTypeName>what should I be passing here</InputMessageTypeName>

 

 

Thanks

Anil

Nov 27, 2009 at 9:31 AM

It seems there is some things that this method doesn't do. Like importing external XSD's. This code should fix that, and I think that's where your problem is (The first 3 lines are there to show you where to put the code). 

 

 

 

 

 

 

 

 

 

 

<font size="2" color="#2b91af"><font size="2" color="#2b91af">

<font size="2" color="#2b91af"><font size="2" color="#2b91af">

ServiceDescription

</font></font><font size="2" color="#2b91af">

 

</font>

wsdl = ServiceDescription.Read(wsdlStream);<font size="2">

 

</font>

 

ServiceDescriptionImporter wsdlImport = new ServiceDescriptionImporter();<font size="2">

wsdlImport.AddServiceDescription(wsdl,

</font>

null, null);

 

<font size="2">

 

</font>

 

//// Add any imported schemas

<font size="2">

 

</font>

 

foreach (System.Xml.Schema.XmlSchema wsdlSchema in

wsdl.Types.Schemas)

{

<font size="2">

 

</font>

 

foreach (System.Xml.Schema.XmlSchemaObject externalSchema in

wsdlSchema.Includes)

{

<font size="2">

 

</font>

 

if (externalSchema is System.Xml.Schema.XmlSchemaImport

)

{

<font size="2">

 

</font>

 

Uri baseUri = new Uri

(wsdlURI);<font size="2">

 

</font>

 

Uri schemaUri = new Uri(baseUri, ((System.Xml.Schema.XmlSchemaExternal

)externalSchema).SchemaLocation);

wsdlStream = client.OpenRead(schemaUri);

<font size="2">

System.Xml.Schema.

</font>

 

XmlSchema schema = System.Xml.Schema.XmlSchema.Read(wsdlStream, null

);

</font></font><font size="2" color="#2b91af">

 

</font>

 

Nov 27, 2009 at 9:35 AM

BTW: The InputMessageTypeName is the name of the content data type in the SOAP body. And if you want to use the HttpRequestResponseStep, you can do that and send in the whole soap envelope. Only thing you have to do is alter the step to take a soap action and put it in the client (http) header.

May 5, 2011 at 2:14 PM

When you are executing the two test cases which contain a SOAPHttpRequestResponseStep, in a same class file in a test project, you will come across an error "TypeLoadException". This is due to the following.

1. In SOAPHttpRequestResponseStep, it reads the WSDL and creates a dot net assembly (proxy) at location such as below.

C:\Documents and Settings\jshaik-s\Local Settings\Application Data\assembly\dl3\LM32OC6R.C2J\1HEYY18D.10E\7e548989\e4d86fbe_190bcc01\TestFrameWorkProxy0.dll

2. This file does not get deleted after the test case execution completes.

3. When the second test case (which has SOAPHttpRequestResponseStep and which exists in the same test project/class) executes it picks up the same file, which corresponds to the earlier test case (wsdl).

4. This results in "Operation Not Found" and "Type Not Found: exceptions.

5. To avoid this modify the BizUnit Code (located in C:\Program Files (x86)\BizUnit\BizUnit 3.1\Src\BizUnit). We need to modify the source code of the class SOAPHttpRequestResponseStep.CS file.

6. Following modified code creates the dll not as TestFrameWorkProxy0.dll, but as TestFrameWorkProxy%New GUID%.dll

7. This avoids the second test case picking up the first test case dll.

 

/// <summary>

/// Returns a name that can be used for the proxy assembly.

/// </summary>

/// <returns></returns>

internal static string GetProxyFileName()

{

int max = 20;

string baseName = "TestFrameWorkProxy";

string fname = "TestFrameWorkProxy.dll";

fname = baseName + System.Guid.NewGuid().ToString() + ".dll";

// try to delete the file if it exists

try

{

File.Delete(fname);

}

catch

{

}

if (!File.Exists(fname))

{

return fname;

}

//for (int i = 0; i <= max; i++)

//{

// fname = baseName + i + ".dll";

// // try to delete the file if it exists

// try

// {

// File.Delete(fname);

// }

// catch

// {

// }

// if (!File.Exists(fname))

// {

// return fname;

// }

//}

return fname;

}