如果我正確理解你的問題,你有兩個WCF方法,一個用於創建一個令牌,另一個用於確認它。 在這種情況下我會做的是有第一種方法,StartRegistration,返回令牌。然後,您可以使用該令牌在Soap UI中輕鬆傳入CompleteRegistration方法。
另一個非常麻煩的解決方案是,在Soap UI中有一個實際連接到郵件帳戶的groovy腳本測試步驟,讀取鏈接並分析內容。
編輯:
下面是你需要的腳本的一部分。將它放在一個常規步驟中,然後將郵件中的令牌返回。
注意:此代碼假定郵件爲純文本,而不是多部分。它還假定郵箱只有一個郵件。 JavaMail的API非常廣泛,所以如果你想用它做任何魔術,谷歌是你的朋友:)至少,這是一個開始的地方。
import javax.mail.*;
import javax.mail.internet.*;
// setup connection
Properties props = new Properties();
def host = "pop3.live.com";
def username = "[email protected]";
def password = "myPassword";
def provider = "pop3s";
// Connect to the POP3 server
Session session = Session.getDefaultInstance props, null
Store store = session.getStore provider
Folder inbox = null
String content
try
{
store.connect host, username, password
// Open the folder
inbox = store.getFolder 'INBOX'
if (!inbox) {
println 'No INBOX'
System.exit 1
}
inbox.open(Folder.READ_ONLY)
Message[] messages = inbox.getMessages()
content = messages[0].getContent()
//Do some parsing of the content here, to find your token.
//Place the result in content
}
finally
{
inbox.close false
store.close()
}
return content; //return the parsed token
由於安全考慮,您建議的第一個解決方案並不合適。我們在服務中有非常安全的令牌算法,令牌不應該暴露給最終客戶端。 – Shailesh 2012-03-15 05:04:35
我對第二種解決方案更感興趣。您可以請張貼一些Groovy腳本樣本。 Thanx幫助我。 – Shailesh 2012-03-15 05:05:18
嗨! 我設法創建了一個閱讀郵件測試步驟,但這一切都取決於您的郵件是什麼樣子。你有一個例子嗎?此外,CompleteRegistration是否將令牌作爲參數? – 2012-03-15 09:52:54