2016-04-14 19 views
1

Gatling ve Scala'da yeniyim. Bir java SOAP web hizmetini Gatling 2.2.0 kullanarak nasıl çağırır/test edebilirim? Ben google ve gatling belgelerine aramış ama bir oGatling kullanarak bir SOAP Web hizmeti nasıl çağırılır 2.2.0

kodu val HTTPprotocol = http .baseURL ("http://PUNITP83267L:8081/WebServiceProject/services/MyService") val headers_0 = Harita ( "-kodlamasını kabul" için herhangi bir bağlantı bulamadı -> "gzip , ", " İçerik Türü "->" text/xml; charset = UTF-8 ", " SOAPAction "->" ", " İçerik Uzunluğu "->" 275 ", " Ana Bilgisayar "- > "PUNITP83267L: 8081", "Bağlantı" -> "canlı", "kabul dili" -> "en-US, tr; q = 0.8", "kullanıcı aracı" -> "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, li) ke Gecko) Chrome/49.0.2623.112 Safari/537,36")

val scn = scenario("SOAPRecordedSimulation") 
     .exec(http("simple Soap Request") 
     .post("<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><greetMeResponse xmlns=\"http://ws.star.fs.infosys.com\"><greetMeReturn>Hello uMESH</greetMeReturn></greetMeResponse></soapenv:Body></soapenv:Envelope>\"\r\n") 
     .headers(headers_0)) 
    setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol) 
} 
+0

SOAP servis çağrısı için herhangi bir kaydedici var mı? SOAP UI kullanarak? – UmeshPathak

cevap

1

bir kaydedici mevcut olup olmadığından emin değil miyim. Ancak, aşağıdaki gibi Betiğinize değişiklikleri yapabilir:

class testSOAP extends Simulation { 

val httpProtocol = http 
      .baseURL("http://PUNITP83267L:8081/WebServiceProject/services/") 

    val header = Map(
    "accept-encoding" -> "gzip, deflate", 
    "Content-Type" -> "text/xml;charset=UTF-8", 
    "SOAPAction" -> "", "Content-Length" -> "275", 
    "Host" -> "PUNITP83267L:8081", 
    "Connection" -> "alive", 
    "accept-language" -> "en-US,en;q=0.8", 
    "user-agent" -> "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36") 

    val scn = scenario("SOAPRecordedSimulation") 
      .exec(http("simple Soap Request") 
      .post("MyService") 
      .headers(header) 
      .body(StringBody("""<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><greetMeResponse xmlns=\"http://ws.star.fs.infosys.com\"><greetMeReturn>Hello uMESH</greetMeReturn></greetMeResponse></soapenv:Body></soapenv:Envelope>\"\r\n"""))) 
     setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol) 
} 
+0

Çok teşekkür ederim Altın. Dokümanlarda nerede bahsediliyor? Bu, Java web hizmeti olduğundan, postada MyService ekledik ve URL değiştirildi (baseURL'den MyService kaldırıldı). Bir .NET web hizmeti ise ne olur? veya hizmet URL'si? WSDL – UmeshPathak

+0

ile biter. MyService'i temel koddan bir kodlama standardı olarak ayırdım. Java veya .NET ile ilgisi yoktur. Ayrıca, .post ("http: // PUNITP83267L: 8081/WebServiceProject/services/MyService") diyebilir ve httpProtocol’ten kurtulabilir. –

0

Ben SAOP kodu bir dosyada olması gerektiğini düşünüyorum ve taban url url bağlamı içermez. Bu sadece temel url (localhost: 7001). Url içeriğini post işlevine koyun.

package my.package 

import scala.concurrent.duration._ 

import io.gatling.core.Predef._ 
import io.gatling.http.Predef._ 
import io.gatling.jdbc.Predef._ 

class MyClass extends Simulation { 

    val httpProtocol = http 
    .baseURL("http://127.0.0.1:7001") 
    .inferHtmlResources() 
    .acceptEncodingHeader("gzip,deflate") 
    .contentTypeHeader("text/xml;charset=UTF-8") 
    .userAgentHeader("Apache-HttpClient/4.1.1 (java 1.5)") 

    val headers_0 = Map("SOAPAction" -> """""""") 

    val uri1 = "http://127.0.0.1:7001/my-project/my-service" 

    val scn = scenario("ScenarioName") 
    .exec(http("request_0") 
     .post("/my-project/my-service") 
     .headers(headers_0) 
     .body(RawFileBody("MyService_0000_request.txt"))) 

    setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol) 
} 

"MyService_0000_request.txt" organları klasör içinde bir dosyadır ve sabun isteği gövdesini içerir: Burada

kodudur.

İlgili konular